Unable to build QtMock in Visual Studio - c++

Just downloaded https://qt.gitorious.org/~niandong/qt/niandongs-qttools/commits/qtmock since I'm in desperate need of mocking a QNetworkAccessManager.
I was able to build the qtmock.pro in QtCreator 2.3.1 using Qt 4.7.4. All the tests ran as they should and I got very exited!
Then I had to build it with visual studio to be able to use the libraries of my project and all of its dependencies. I'm using Qt 4.8 here in Visual Studio 2010 pro. I imported the main qtmock.pro and first I tried to build the underlying qtmock project that only contains the framework (no tests or anything). It built fine and I got a .lib and .dll file. Then I tried to build the qtnetworkstub.pro where all the mock objects for QNetwork are which I need for my project. The following is my command line for the build:
/OUT:"......\lib\qtnetworkmock.dll" /NOLOGO
/LIBPATH:"E:\QT\4.8.0\lib" /LIBPATH:"e:\QT\4.8.0\lib"
/LIBPATH:"../../../lib" /DLL "../../../lib\qtmock.lib"
"E:\QT\4.8.0\lib\QtTestd4.lib" "E:\QT\4.8.0\lib\QtCored4.lib"
"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib"
"advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib"
"odbc32.lib" "odbccp32.lib" /MANIFEST
/ManifestFile:"Win32\qtnetworkmock.dll.intermediate.manifest"
/ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/DEBUG /PDB:"E:.Qt.UnitTest\qtmock\lib\qtnetworkmock.pdb"
/PGD:"E:\src\Qt.UnitTest\qtmock\lib\qtnetworkmock.pgd" /TLBID:1
/DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
and I'm only using the testLib and the Core.
I then got the following linkin error:
Error 4 error LNK2019: unresolved external symbol "public: static struct QMetaObject const QAbstractSocket::staticMetaObject" (?staticMetaObject#QAbstractSocket##2UQMetaObject##B) referenced in function "public: __thiscall QNetworkRequest::~QNetworkRequest(void)" (??1QNetworkRequest##QAE#XZ) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkrequest.obj qtnetworkstub
Error 5 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QTcpSocket::staticMetaObject" (?staticMetaObject#QTcpSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkreply.obj qtnetworkstub
Error 6 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QTcpSocket::staticMetaObject" (?staticMetaObject#QTcpSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkrequest.obj qtnetworkstub
Error 7 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QSslSocket::staticMetaObject" (?staticMetaObject#QSslSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkreply.obj qtnetworkstub
Error 8 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QSslSocket::staticMetaObject" (?staticMetaObject#QSslSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkrequest.obj qtnetworkstub
Error 1 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QAbstractSocket::staticMetaObject" (?staticMetaObject#QAbstractSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkaccessmanager.obj qtnetworkstub
Error 2 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QAbstractSocket::staticMetaObject" (?staticMetaObject#QAbstractSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkproxy.obj qtnetworkstub
Error 3 error LNK2001: unresolved external symbol "public: static struct QMetaObject const QAbstractSocket::staticMetaObject" (?staticMetaObject#QAbstractSocket##2UQMetaObject##B) E:\src\Qt.UnitTest\qtmock\test\stublib\network\qnetworkreply.obj qtnetworkstub
Error 9 error LNK1120: 3 unresolved externals E:\src\Qt.UnitTest\qtmock\lib\\qtnetworkmock.dll qtnetworkstub
The thing that I dont get is: I'm not using any of these objects and they arent refered anywhere in that project. All of them inherits from QIODevice but I'm not too sure how much that will help.
I'm extremy stuck and I would appreciate any help since I really want to use this framework (it seems really great for unit testing!)

Apparently this is an issue with QTMock and Qt 4.8 and has nothing to do with visual studio. The current available build of QtMock does not work with 4.8 (only 4.7 and possibly lower) but will be fixed very soon.

Related

Static library not linking correctly

sorry to bother you.
I know this is a commonly asked question and this is probably annoying to get again but I'm just completely stuck and not sure what I'm doing wrong.
I'm following learnopengl.com and trying to add assimp to my CLion project.
I created a new project quickly just so I know nothing is interfering.
I have a folder on my C drive where I placed in assimp library.
I downloaded it by following https://github.com/assimp/assimp/blob/master/Build.md with git and doing
cd assimp
cmake CMakeLists.txt
but changing the BUILD_SHARED_LIBS to OFF
Then I build the library with visual studio 2022 Using "Release x64" and the "Visual Studio 2022 (v143)" toolset
I link to the library with CMake as below.
I don't get an error message so I know that CMake finds the library.
I also have the location to the library setup in the PATH.
cmake_minimum_required(VERSION 3.22)
project(lemmefixbroken)
set(CMAKE_CXX_STANDARD 20)
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_executable(lemmefixbroken main.cpp)
# assimp
include_directories("C:/dev/libraries/assimp/include")
find_library(ASSIMP_LOCATION NAMES "assimp-vc143-mt" REQUIRED)
message(${ASSIMP_LOCATION})
target_link_libraries(${PROJECT_NAME} "${ASSIMP_LOCATION}")
My compiler settings are as below:
(Using the compiler located in Visual Studio 2022 and using the architecture amd64)
I've tried all the different architectures but none work.
The message returns "C:/dev/libraries/assimp/lib/Release/assimp-vc143-mt.lib" which is where its located
My code is:
#include <iostream>
#include "assimp/Importer.hpp"
int main()
{
std::cout << "Hello, World!" << std::endl;
Assimp::Importer import;
return 0;
}
When I build the code I get this error:
"C:\Program Files\JetBrains\CLion 2022.1.1\bin\cmake\win\bin\cmake.exe" --build C:\Users\charl\CLionProjects\lemmefixbroken\cmake-build-release --target all -j 9
[1/2] Building CXX object CMakeFiles\lemmefixbroken.dir\main.cpp.obj
[2/2] Linking CXX executable lemmefixbroken.exe
FAILED: lemmefixbroken.exe
cmd.exe /C "cd . && "C:\Program Files\JetBrains\CLion 2022.1.1\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\lemmefixbroken.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo CMakeFiles\lemmefixbroken.dir\main.cpp.obj /out:lemmefixbroken.exe /implib:lemmefixbroken.lib /pdb:lemmefixbroken.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console C:\dev\libraries\assimp\lib\Release\assimp-vc143-mt.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo CMakeFiles\lemmefixbroken.dir\main.cpp.obj /out:lemmefixbroken.exe /implib:lemmefixbroken.lib /pdb:lemmefixbroken.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console C:\dev\libraries\assimp\lib\Release\assimp-vc143-mt.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:lemmefixbroken.exe.manifest" failed (exit code 1120) with the following output:
assimp-vc143-mt.lib(AssbinLoader.obj) : error LNK2019: unresolved external symbol uncompress referenced in function "public: virtual void __cdecl Assimp::AssbinImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile#AssbinImporter#Assimp##UEAAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEAUaiScene##PEAVIOSystem#2##Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflate referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompress(void const *,unsigned __int64,class std::vector<char,class std::allocator<char> > &)" (?decompress#Compression#Assimp##QEAA_KPEBX_KAEAV?$vector#DV?$allocator#D#std###std###Z)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflate
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateEnd referenced in function "public: bool __cdecl Assimp::Compression::close(void)" (?close#Compression#Assimp##QEAA_NXZ)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflateEnd
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateSetDictionary referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompressBlock(void const *,unsigned __int64,char *,unsigned __int64)" (?decompressBlock#Compression#Assimp##QEAA_KPEBX_KPEAD1#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateReset referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompressBlock(void const *,unsigned __int64,char *,unsigned __int64)" (?decompressBlock#Compression#Assimp##QEAA_KPEBX_KPEAD1#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateInit_ referenced in function "public: bool __cdecl Assimp::Compression::open(enum Assimp::Compression::Format,enum Assimp::Compression::FlushMode,int)" (?open#Compression#Assimp##QEAA_NW4Format#12#W4FlushMode#12#H#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function "public: bool __cdecl Assimp::Compression::open(enum Assimp::Compression::Format,enum Assimp::Compression::FlushMode,int)" (?open#Compression#Assimp##QEAA_NW4Format#12#W4FlushMode#12#H#Z)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflateInit2_
assimp-vc143-mt.lib(unzip.obj) : error LNK2019: unresolved external symbol crc32 referenced in function unzReadCurrentFile
assimp-vc143-mt.lib(unzip.obj) : error LNK2019: unresolved external symbol get_crc_table referenced in function unzOpenCurrentFile3
lemmefixbroken.exe : fatal error LNK1120: 9 unresolved externals
ninja: build stopped: subcommand failed.
I've tried compiling the library more times than I would like to count. I've tried using the 2019 compiler and nothing. I still get all the same errors.
I have no clue what I'm doing wrong but hopefully someone here will know.
I've also tried using shared libraries with no success.
I've updated Visual Studio 2022 and restarted my computer then compiling again and still nothing changes.
Those are all zlib symbols that are missing, which means you didn't link against that. Asset-Importer lists several dependencies:
zlib
zip-lib
unzip
pugi-xml
rapijson
clipper
draco
gtest
stb_image
utf8cpp
poly2tri
openddlparser
Since Findassimp.cmake uses an old path-based interface instead of the newer style of defining virtual targets that can have PUBLIC dependencies, you will need to link against those yourself. They're all in the library's source tree, but having never used the library I don't know if they get built as part of its build scripts of if you would need to do that yourself.
As you can see in the error messages, what failed is the linking process, not the compiling process.
I think your linker could not find the assimp library's '.lib' files.
Did you specify the path to the assimp library's '.lib' files in the project setting?
You could do this in 'VC++ Directories' or 'Linker/Input', though I'm not sure since I'm not using my computer at the moment.

Linking against 32 bit boost libraries

I'm trying to link my project against a couple of boost libraries and I ran into a 32 vs 64 bit problem.
I'm using Visual Studio 2015. I added path to the built boost libraries to VC++ Directories.
Here's the output I get:
2>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall boost::thread::detach(void)" (?detach#thread#boost##QAEXXZ)
2>main.obj : error LNK2001: unresolved external symbol "private: bool __thiscall boost::thread::start_thread_noexcept(void)" (?start_thread_noexcept#thread#boost##AAE_NXZ)
2>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAABVerror_category#12#XZ)
2>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAABVerror_category#12#XZ)
2>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::detail::thread_data_base::~thread_data_base(void)" (??1thread_data_base#detail#boost##UAE#XZ)
I'm building boost using bootstrap like this:
b2 -j8 toolset=msvc-14.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage32
While searching for the solution I opened libboost_thread-vc140-mt-1_64.lib with a text editor and found functions that linker can't find to look like this ?detach#thread#boost##QEAAXXZ
Some sources explain that QEAAXXZ is a name of a 64-bit compiled function. My linker though expects QAEXXZ (32-bit) as you can see from the output.
Am I building boost correctly for a 32-bit application? If so, why can't my application link against it?

error lnk2019 unresolved external symbol public __thiscall sfml audio module

Im having great troubles compiling a simple test project using with SFML.
I have seen many errors similar to the ones Im getting on the internet but everything i tried failed.
I am static linking sfml.
In the project's properties, I added the path to the SFML headers and the SFML libraries.
I have define the SFML_STATIC macro in the preprocessor options of my project.
I added modules and their dependencies like so :
sfml-audio-s.lib sfml-audio-s-d.lib sfml-graphics-s.lib
sfml-graphics-s-d.lib sfml-window-s.lib sfml-window-s-d.lib
sfml-system-s.lib sfml-system-s-d.lib opengl32.lib freetype.lib
jpeg.lib winmm.lib flac.lib vorbis.lib vorbisenc.lib vorbisfile.lib
ogg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib
I even added the dll files in my executable folder even though its not necessary when static building.
here is my code :
#include "stdafx.h"
#include <SFML/Audio.hpp>
#include <iostream>
#include <stdlib.h>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "helloo" << std::endl;
sf::SoundBuffer buffer;
if (!buffer.loadFromFile("A4.wav"))
std::cout << "cant open file" << std::endl;
sf::Sound sound;
sound.setBuffer(buffer);
sound.play();
_sleep(5000);
return 42;
}
And now here is the errors I get :
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::~SoundBuffer(void)" (??1SoundBuffer#sf##QAE#XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Sound::~Sound(void)" (??1Sound#sf##UAE#XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::play(void)" (?play#Sound#sf##QAEXXZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::setBuffer(class sf::SoundBuffer const &)" (?setBuffer#Sound#sf##QAEXABVSoundBuffer#2##Z) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Sound::Sound(void)" (??0Sound#sf##QAE#XZ) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::SoundBuffer::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?loadFromFile#SoundBuffer#sf##QAE_NABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function _wmain
1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::SoundBuffer(void)" (??0SoundBuffer#sf##QAE#XZ) referenced in function _wmain
additionnal infos :
Im using visual studio 2010 express.
I downloaded "SFML 2.3 Visual C++ 10 (2010) - 64-bit".
any help appreciated.
EDIT : as I said I tried many things, I have read a LOT of stack overflow or other forums posts, nothing worked... I have been stuck on this for 2 weeks now.
I'd really appreciate some help

Building a static library for glut 3.7 on Windows

I've been trying to compile glut as a static library without having to link with glut32.dll on runtime. I downloaded the glut windows source code but when I try to compile (default), I keep getting:
Making in glut subdirectory...
link /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup#12 -dll -out:glut32.dll -def:glut.def glut_8x13.obj glut_9x15.obj glut_bitmap.obj glut_bwidth.obj glut_cindex.obj glut_cmap.obj glut_cu
rsor.obj glut_dials.obj glut_dstr.obj glut_event.obj glut_ext.obj glut_fullscrn.obj glut_gamemode.obj glut_get.obj glut_hel10.obj glut_hel12.obj glut_hel18.obj glut_init.obj glut_input.obj glut_joy.ob
j glut_key.obj glut_keyctrl.obj glut_keyup.obj glut_mesa.obj glut_modifier.obj glut_mroman.obj glut_overlay.obj glut_roman.obj glut_shapes.obj glut_space.obj glut_stroke.obj glut_swap.obj glut_swidth.
obj glut_tablet.obj glut_teapot.obj glut_tr10.obj glut_tr24.obj glut_util.obj glut_vidresize.obj glut_warp.obj glut_win.obj glut_winmisc.obj win32_glx.obj win32_menu.obj win32_util.obj win32_winproc.o
bj win32_x11.obj opengl32.lib glu32.lib winmm.lib kernel32.lib ws2_32.lib mswsock.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib
LINK : fatal error LNK1104: cannot open file 'glut32.lib'
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : return code '0x450'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.EXE"' : return code '0x2'
Stop.
From what I understand, glut32.lib should be compiled and created in {source}\lib\glut\ but it's not there.
Any help compiling a static library for glut would be appreciated.
Edit:
In Makefile.win
Changed:
$(link) $(LFLAGS) -out:$(GLUTDLL) -def:glut.def $(OBJS) $(LIBS)
to
lib $(OBJS) $(LIBS)
It generated \lib\glut\glut_8x13.lib not sure what the 8x13 is about but when I tried to link with it, I got some unresolved externals:
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutCreateWindow#4 referenced in function "protected: __thiscall GlobalDecl::OpenGLConte
xt::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext#GlobalDecl##IAE#II#Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowSize#8 referenced in function "protected: __thiscall GlobalDecl::OpenGLCon
text::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext#GlobalDecl##IAE#II#Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitWindowPosition#8 referenced in function "protected: __thiscall GlobalDecl::OpenG
LContext::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext#GlobalDecl##IAE#II#Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInitDisplayMode#4 referenced in function "protected: __thiscall GlobalDecl::OpenGLCo
ntext::OpenGLContext(unsigned int,unsigned int)" (??0OpenGLContext#GlobalDecl##IAE#II#Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutInit#8 referenced in function "protected: __thiscall GlobalDecl::OpenGLContext::Open
GLContext(unsigned int,unsigned int)" (??0OpenGLContext#GlobalDecl##IAE#II#Z)
GPURenderer_test.obj : error LNK2019: unresolved external symbol __imp__glutSwapBuffers#0 referenced in function "protected: void __thiscall GlobalDecl::OpenGLC
ontext::_executeTest(class GlobalDecl::UnitTest &)" (?_executeTest#OpenGLContext#GlobalDecl##IAEXAAVUnitTest#2##Z)
Thanks,
Ryan
It looks to me like you have something pretty badly munged up in your build setup (or you're using the wrong build setup completely, such as trying to build some samples before you've built the library they use).
To build a static library, you shouldn't be running link at all. For a static library, you compile your object files, then use lib to put them together into a library. You'd use link to build a dynamic library (DLL) or an executable, but not a static library.

linker error after compiling

Im having a problem with the linker i guess
This is what i get on the output tab:
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function "private: unsigned int __thiscall objloader::loadTexture(char const *)" (?loadTexture#objloader##AAEIPBD#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function "private: unsigned int __thiscall objloader::loadTexture(char const *)" (?loadTexture#objloader##AAEIPBD#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function "private: unsigned int __thiscall objloader::loadTexture(char const *)" (?loadTexture#objloader##AAEIPBD#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_GetTicks referenced in function "public: void __thiscall Player::init(void)" (?init#Player##QAEXXZ)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_GetKeyState referenced in function "void __cdecl Control(float,float,bool)" (?Control##YAXMM_N#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_WarpMouse referenced in function "void __cdecl Control(float,float,bool)" (?Control##YAXMM_N#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_GetMouseState referenced in function "void __cdecl Control(float,float,bool)" (?Control##YAXMM_N#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_ShowCursor referenced in function "void __cdecl Control(float,float,bool)" (?Control##YAXMM_N#Z)
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_Delay referenced in function _SDL_main
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_GL_SwapBuffers referenced in function _SDL_main
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_PollEvent referenced in function _SDL_main
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main
1>main-light.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
1>MSVCRT.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\Tiago\Desktop\Projects\FPS\Debug\FPS.exe : fatal error LNK1120: 14 unresolved externals
here is the command line of the linker (if it can help you...):
/OUT:"C:\Users\Tiago\Desktop\Projects\FPS\Debug\FPS.exe" /NOLOGO "SDL.lib" "SDLmain.lib" "glu32.lib" "glut32.lib" "opengl32.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\FPS.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Tiago\Desktop\Projects\FPS\Debug\FPS.pdb" /SUBSYSTEM:CONSOLE /PGD:"C:\Users\Tiago\Desktop\Projects\FPS\Debug\FPS.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE
More information:
i've put the OpenGL and SDL folder (the folder with the include and lib files) in the main folder of my project. Is it causing the problem?
I cannot find anything relevant in the SDL docs on how to configure your project properly. The header files gives some hints, it uses non-standard #defines to select the platform. Which explains the first set of linker errors, the DECLSPEC macro has to be set correctly. For some really mysterious reason it wants to rename main() as well, the reason for your last linker error. No clue why any of this is necessary, these kind of hacks tend to be used as a filter. As in, "can't figure this out by yourself, don't bug us with your other questions".
First thing you have to do: right-click your project, Properties, Linker, Advanced, Entry Point = SDL_main. Make your code look similar to this, I hard-coded the paths and told the linker what to link:
include "stdafx.h"
#define __WIN32__ // Non-standard define to select the platform
#include "c:/temp/sdl-1.2.15/include/sdl.h"
#pragma comment(lib, "c:/temp/sdl-1.2.15/lib/x86/sdl.lib")
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_EVERYTHING); // Just an example
// etc...
return 0;
}
It linked correctly, that's all I tried. Running it requires sdl.dll in the same directory as your .exe. Good luck with it, sounds like you'll need it.