ROSOnWindows
ROSOnWindows copied to clipboard
Linking error with C++ project that links SDL
Describe the bug Any C++ project that links to SDL fails to compile. Searching for the error, I found https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2 , that indicates that the problem may be that the binary version of SDL distributed in chocolatey was built with an old version of Visual Studio.
To Reproduce
After executing setup.bat, try to compile in Release a simple project that uses SDL https://gist.github.com/traversaro/c8d9b2aa7c197e0d12dc44759f0e4d4a :
git clone https://gist.github.com/traversaro/c8d9b2aa7c197e0d12dc44759f0e4d4a test_SDL
cd test_SDL
md build
cd build
cmake -A x64 ..
cmake --build . --config Release
The last command results in the following error:
C:\src\test_SDL\build>cmake --build . --config Release
<...>
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\src\test_sdl\build\Release\SDL_test.exe" /INCREMENTAL:NO /NOLOGO C
:\opt\rosdeps\x64\lib\SDLmain.lib C:\opt\rosdeps\x64\lib\SDL.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"le
vel='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/src/test_sdl/build/Release/SDL_test.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/src/test_sdl/build/Release/SDL_test.lib" /MAC
HINE:X64 /machine:x64 SDL_test.dir\Release\SDL_test.obj
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol SDL_main referenced in function main [C:\src\test_sdl\build\SDL_test.vcxproj]
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp_fprintf referenced in function ShowError [C:\src\test_sdl\build\SDL_test.vcxproj]
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp___iob_func referenced in function ShowError [C:\src\test_sdl\build\SDL_test.vcxproj]
C:\src\test_sdl\build\Release\SDL_test.exe : fatal error LNK1120: 3 unresolved externals [C:\src\test_sdl\build\SDL_test.vcxproj]
Done Building Project "C:\src\test_sdl\build\SDL_test.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\src\test_sdl\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\src\test_sdl\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\src\test_sdl\build\SDL_test.vcxproj" (default target) (3) ->
(Link target) ->
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol SDL_main referenced in function main [C:\src\test_sdl\build\SDL_test.vcxproj]
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp_fprintf referenced in function ShowError [C:\src\test_sdl\build\SDL_test.vcxproj]
SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol __imp___iob_func referenced in function ShowError [C:\src\test_sdl\build\SDL_test.vcxproj]
C:\src\test_sdl\build\Release\SDL_test.exe : fatal error LNK1120: 3 unresolved externals [C:\src\test_sdl\build\SDL_test.vcxproj]
0 Warning(s)
4 Error(s)
Time Elapsed 00:00:03.26
C:\src\test_sdl\build>
Expected behavior I would expect to be able to compile any C++ program that links SDL.
Environment information:
- OS version:
Windows Version 1709 - OS Build 16299.192 - Chocolatey Versions:
C:\src\test-tinyxml\build>choco list --local-only
Chocolatey v0.10.11
assimp 4.0.1.1809242322
boost 1.66.0.1809242326
bullet3 2.87.0.1809242326
bzip2 1.0.6.1809242322
chocolatey 0.10.11
console_bridge 0.4.0.1809242322
cppunit 1.12.1.1809242322
eigen 3.3.4.1809242322
freeglut 3.0.0.1809242322
google-mock 1.8.0.1809242326
google-test 1.8.0.1809242322
libcurl 7.58.0.1809242322
libgraphviz 2.41.0.1810022039
libopencv 3.4.1.1809242322
log4cxx 0.10.0.1809242322
lz4 1.8.1.1809242322
ogre 1.10.11.1809100020
openssl 1.1.1.1809242322
pkg-config 0.29.2.1809242322
poco 1.8.1.1809242322
pyqt5 5.10.1.1809242322
pyside2 5.10.1.1809242322
qt5-sdk 5.10.1.1810112239
ros-catkin-tools 0.0.1.1810092059
ros-cmake 3.11.4.1809242322
ros-melodic-desktop 20181027.1
ros-python2 2.7.15.1809242354
sbcl 0.0.0.1809242326
sdl 1.2.15.1809242322
sdl_image 1.2.12.1809242322
sip 4.19.8.1809242322
tinyxml 2.6.2.1809242322
tinyxml2 6.1.0.1809242322
urdfdom 1.0.0.1809242322
urdfdom_headers 1.0.0.1809242322
vcpython27 9.0.30729.1809090720
yaml-cpp 0.5.3.1809242322
37 packages installed.