Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Fix Windows Overlay PNG linking issue. #778

Merged
merged 2 commits into from
Jun 4, 2018
Merged

CMake: Fix Windows Overlay PNG linking issue. #778

merged 2 commits into from
Jun 4, 2018

Conversation

gszadkow
Copy link
Contributor

@gszadkow gszadkow commented Jun 3, 2018

  • Building libpng from patched sources.
  • Linking to Overlay

- Building libpng from patched sources.
- Linking to Overlay
@paroj
Copy link
Member

paroj commented Jun 4, 2018

how is this needed? The Overlay component neither directly nor indirectly links against against libpng. Only the optional freeimage plugin uses libpng via freeimage.

@gszadkow
Copy link
Contributor Author

gszadkow commented Jun 4, 2018

Steps to reproduce:

git clone https://github.com/OGRECave/ogre.git
mkdir ogre-build
cd ogre-build
mkdir RelWithDebInfo
cd RelWithDebInfo
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" ../../ogre
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe"  OGRE.sln //p:Configuration=RelWithDebInfo //p:Platform=x64

or:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" Components/Overlay/OgreOverlay.sln //p:Configuration=RelWithDebInfo //p:Platform=x6

...
Output: Link: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\gszadkow\repositories\ogre-build\RelWithDebInfo\bin\RelWithDebInfo\OgreOverlay.dll" /INCREMENTAL /NOLOGO ..\..\lib\RelWithDebInfo\OgreMain.lib ..\..\Dependencies\lib\freetype.lib "C:\Anaconda3-x64\Library\lib\z.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/gszadkow/repositories/ogre-build/RelWithDebInfo/bin/RelWithDebInfo/OgreOverlay.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/gszadkow/repositories/ogre-build/RelWithDebInfo/lib/RelWithDebInfo/OgreOverlay.lib" /MACHINE:X64 /machine:x64 /DLL OgreOverlay.dir\RelWithDebInfo\OgreBorderPanelOverlayElement.obj OgreOverlay.dir\RelWithDebInfo\OgreFont.obj OgreOverlay.dir\RelWithDebInfo\OgreFontManager.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlay.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayContainer.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayElement.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayElementCommands.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayElementFactory.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayManager.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayProfileSessionListener.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlaySystem.obj OgreOverlay.dir\RelWithDebInfo\OgreOverlayTranslator.obj OgreOverlay.dir\RelWithDebInfo\OgrePanelOverlayElement.obj OgreOverlay.dir\RelWithDebInfo\OgreTextAreaOverlayElement.obj Creating library C:/gszadkow/repositories/ogre-build/RelWithDebInfo/lib/RelWithDebInfo/OgreOverlay.lib and object C:/gszadkow/repositories/ogre-build/RelWithDebInfo/lib/RelWithDebInfo/OgreOverlay.exp freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_create_read_struct referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_longjmp_fn referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_create_info_struct referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_read_info referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_expand_gray_1_2_4_to_8 referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_palette_to_rgb referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_tRNS_to_alpha referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_gray_to_rgb referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_filler referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_packing referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_interlace_handling referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_strip_16 referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_read_update_info referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_read_image referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_read_end referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_destroy_read_struct referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_get_error_ptr referenced in function error_callback [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_read_fn referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_get_io_ptr referenced in function read_data_from_FT_Stream [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_set_read_user_transform_fn referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_error referenced in function read_data_from_FT_Stream [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_get_valid referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] freetype.lib(sfnt.obj) : error LNK2019: unresolved external symbol png_get_IHDR referenced in function Load_SBit_Png [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] C:\gszadkow\repositories\ogre-build\RelWithDebInfo\bin\RelWithDebInfo\OgreOverlay.dll : fatal error LNK1120: 23 unresolved externals [C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj] Done Building Project "C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj" (default targets) -- FAILED. Done Building Project "C:\gszadkow\repositories\ogre-build\RelWithDebInfo\Components\Overlay\OgreOverlay.vcxproj.metaproj" (default targets) -- FAILED.

You can also reproduce this from CMake GUI and MSVC, but I find CLI more convinient to reproduce/automate build.
Also, I found Forum Topic about the same issue.

Linking PNG to Overlay target as in proposed solution solved issue for me.

@paroj
Copy link
Member

paroj commented Jun 4, 2018

somehow freetype picks up png on your system, which it should not. Try force disabling it by adding
-DWITH_PNG=OFF to freetype.

@gszadkow
Copy link
Contributor Author

gszadkow commented Jun 4, 2018

Now it seems to build without any problems for all configurations

mkdir Debug
cd Debug
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE:STRING="Debug" ../../ogre
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" OGRE.sln //p:Configuration=Debug //p:Platform=x64
cd ../  

mkdir Release
cd Release
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE:STRING="Release" ../../ogre
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" OGRE.sln //p:Configuration=Release //p:Platform=x64
cd ../  

mkdir RelWithDebInfo
cd RelWithDebInfo
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" ../../ogre
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" OGRE.sln //p:Configuration=RelWithDebInfo //p:Platform=x64
cd ../  

mkdir MinSizeRel
cd MinSizeRel
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE:STRING="MinSizeRel" ../../ogre
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" OGRE.sln //p:Configuration=MinSizeRel //p:Platform=x64
cd ../  

@paroj paroj merged commit b5bb4d3 into OGRECave:master Jun 4, 2018
@paroj
Copy link
Member

paroj commented Jun 4, 2018

thanks 👍

darksylinc added a commit to darksylinc/ogre that referenced this pull request Jul 25, 2018
Improvements on Terra system

--HG--
branch : v2-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants