I'm attempting to set up a build system named Waf with a test C++ OpenGL/SDL project, and am running into a few issues with the linking process. As far as I can tell, all of the libraries are being found properly, and being added into the linking command, and yet the linking process seems to be acting as if the libraries aren't linked.
In order to attempt to debug the process, I was trying to run the compilation/link process manually in order to understand exactly how it works with MSVC, but I'm still getting issues. When I run the following LINK.exe command:
PS C:\Users\covertcj\Documents\projects\test> & "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\amd64\LINK.exe"
/NOLOGO /MANIFEST /SUBSYSTEM:CONSOLE /MACHINE:x64 /VERBOSE
.\build\src\main.cpp.1.o
/OUT:.\build\test.exe
/LIBPATH:C:\Users\covertcj\Documents\projects\test\lib /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64"
opengl32.lib sdl.lib sdlmain.lib
I get the same error as usual:
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_CreateWindow referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_DestroyWindow referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_GL_CreateContext referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_GL_SwapWindow referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_GL_DeleteContext referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_PollEvent referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_Delay referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_Init referenced in function SDL_main
main.cpp.1.o : error LNK2019: unresolved external symbol SDL_Quit referenced in function SDL_main
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
However, I also get some interesting verbose output:
Searching libraries
Searching C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64\opengl32.lib:
Searching C:\Users\covertcj\Documents\projects\dungeonhg\lib\sdl.lib:
Searching C:\Users\covertcj\Documents\projects\dungeonhg\lib\sdlmain.lib:
Searching C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\LIBCMT.lib:
Found _load_config_used
Loaded LIBCMT.lib(loadcfg.obj)
Searching C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\OLDNAMES.lib:
Searching C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64\kernel32.lib:
Finished searching libraries
Unused libraries:
C:\Users\covertcj\Documents\projects\dungeonhg\lib\sdl.lib
C:\Users\covertcj\Documents\projects\dungeonhg\lib\sdlmain.lib
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\OLDNAMES.lib
However, my code most definitely uses SDL and SDLmain:
main.cpp
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
int main(int argc, char *argv[]) {
SDL_Init(SDL_INIT_VIDEO); // Init SDL2
// Create a window. Window mode MUST include SDL_WINDOW_OPENGL for use with OpenGL.
SDL_Window *window = SDL_CreateWindow(
"SDL2/OpenGL Demo", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE
);
...
Anybody know what I'm doing wrong here?
EDIT: I have also verified that the same waf script works on both linux and osx, so it seems to be windows specific.
I think your main problem is
error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
which might be the one error where everything else hinges. If I had to guess, I would have to assume that you forgot to add a "main" function... although apparently you didn't, as I can clearly see it in your posting.
Related
I'm trying to build poco library (c++) with openssl on windows 10 (VS 2012). With the following cmd file:
#echo off
set INCLUDE=c:\openssl\include
set LIB=c:\openssl\lib
set _IsNativeEnvironment=true
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat"
buildwin 110 build all release x64 nosamples notests devenv
I get link errors:
1>------ Build started: Project: Crypto, Configuration: release_shared x64 ------
1> Datei *.dll nicht gefunden
1> Datei *.lib nicht gefunden
1> Creating library ..\lib64\PocoCrypto.lib and object ..\lib64\PocoCrypto.exp
1>ECKey.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>ECKeyImpl.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>RSAKeyImpl.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>PKCS12Container.obj : error LNK2001: unresolved external symbol EVP_PKEY_type
1>EVPPKey.obj : error LNK2019: unresolved external symbol EVP_PKEY_type referenced in function "private: void __cdecl Poco::Crypto::EVPPKey::newECKey(char const *)" (?newECKey#EVPPKey#Crypto#Poco##AEAAXPEBD#Z)
...
(Datei *.dll nicht gefunden == file *.dll not found).
If I remove the Crypto in file "components" (Is it OK if I want to use https?), I get the following error:
1>------ Build started: Project: NetSSL_OpenSSL, Configuration: release_shared x64 ------
1> Creating library ..\lib64\PocoNetSSL.lib and object ..\lib64\PocoNetSSL.exp
1>Context.obj : error LNK2019: unresolved external symbol BIO_new_file referenced in function "private: void __cdecl Poco::Net::Context::initDH(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?initDH#Context#Net#Poco##AEAAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
...
I installed openssl from "Shining Light" (win64). I also tried to use openssl which is built from source (https://github.com/pocoproject/openssl). But I get the same errors.
Can someone help me ?!
Thank you!
Xinyu
OK, If I delete all object files: folder obj64, including obj64 in testsuite, then every thing is ok.
I download boost1.55 zip from official website and then build with command bootstrap and b2.
And I tried example code, but it has a link error.
1>LINK : fatal error LNK1104: cannot open file 'libboost_python-vc120-mt-gd-1_55.lib'
Below is what I did.
New project win32 Console application, DLL empty.
Add include path, library path in VC++ DIRECTORIES like the below.
INCLUDE DIRECTORIES: C:\boost\boost_1_55_0;C:\Python27\include
LIBRARY DIRECTORIES: C:\boost\boost_1_55_0\libs;C:\Python27\libs
.
#define BOOST_PYTHON_STATIC_LIB
#include <boost/python.hpp>
using namespace boost::python;
struct World
{
void set(std::string msg) { this->msg = msg; }
std::string greet() { return msg; }
std::string msg;
};
BOOST_PYTHON_MODULE(hello)
{
class_<World>("World")
.def("greet", &World::greet)
.def("set", &World::set);
}
Edit
If i add the library directory, C:\boost_1_55_0\stage\liblike an answer below, it make many errors happen, around 200
below is just the part of errors.
1>------ Build started: Project: hello, Configuration: Debug Win32
------ 1> hello.cpp 1>c:\python27\include\pymath.h(22): warning C4273: 'round' : inconsistent dll linkage 1> c:\program files
(x86)\microsoft visual studio 12.0\vc\include\math.h(516) : see
previous definition of 'round' 1>c:\program files (x86)\microsoft
visual studio 12.0\vc\include\xtgmath.h(190): warning C4273: '_hypot'
: inconsistent dll linkage 1> c:\program files
(x86)\microsoft visual studio 12.0\vc\include\math.h(538) : see
previous definition of '_hypot' 1>c:\program files (x86)\microsoft
visual studio 12.0\vc\include\xtgmath.h(206): warning C4273: 'round' :
inconsistent dll linkage 1> c:\program files (x86)\microsoft
visual studio 12.0\vc\include\math.h(516) : see previous definition of
'round' 1>c:\boost_1_55_0\boost\python\opaque_pointer_converter.hpp :
warning C4819: The file contains a character that cannot be
represented in the current code page (949). Save the file in Unicode
format to prevent data loss
1>c:\boost_1_55_0\boost\python\return_opaque_pointer.hpp : warning
C4819: The file contains a character that cannot be represented in the
current code page (949). Save the file in Unicode format to prevent
data loss 1> Creating library C:\Users\User\documents\visual studio
2013\Projects\hello\Debug\hello.lib and object
C:\Users\User\documents\visual studio
2013\Projects\hello\Debug\hello.exp 1>hello.obj : error LNK2019:
unresolved external symbol __imp__PyString_FromStringAndSize
referenced in function "public: struct _object * __thiscall
boost::python::to_python_value,class std::allocator > const
&>::operator()(class std::basic_string,class std::allocator > const &)const "
(??R?$to_python_value#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###python#boost##QBEPAU_object##ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
1>libboost_python-vc120-mt-gd-1_55.lib(builtin_converters.obj) : error
LNK2001: unresolved external symbol __imp__PyString_FromStringAndSize
1>libboost_python-vc120-mt-gd-1_55.lib(str.obj) : error LNK2001:
unresolved external symbol __imp__PyString_FromStringAndSize
1>libboost_python-vc120-mt-gd-1_55.lib(function_doc_signature.obj) :
error LNK2001: unresolved external symbol
__imp__PyString_FromStringAndSize 1>libboost_python-vc120-mt-gd-1_55.lib(list.obj) : error LNK2001:
unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(tuple.obj) : error LNK2001:
unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(function_doc_signature.obj) :
error LNK2001: unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(object_protocol.obj) : error
LNK2001: unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(pickle_support.obj) : error
LNK2001: unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(dict.obj) : error LNK2001:
unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(str.obj) : error LNK2001:
unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(from_python.obj) : error
LNK2001: unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(function.obj) : error LNK2001:
unresolved external symbol __imp___Py_NoneStruct
1>libboost_python-vc120-mt-gd-1_55.lib(module.obj) : error LNK2001:
The "LIBRARY DIRECTORY" should reference C:\boost_1_55_0\stage\lib instead of C:\boost\boost_1_55_0\libs.
I've tried to build M2Crypto (github) for win-amd64-py3.3:
python setup.py build --compiler msvc
And I've got an linker's unresolved external symbol errors (full log):
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\Programy\Python33\libs /LIBPATH:D:\Programy\Python33\PCbuild\amd64 /LIBPATH:c:\pkg\lib ssleay32.lib libeay32.lib /EXPORT:PyInit___m2crypto build\temp.win-amd64-3.3\Release\SWIG/_m2crypto_wrap.obj /OUT:build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd /IMPLIB:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib /MANIFESTFILE:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.pyd.manifest
_m2crypto_wrap.obj : warning LNK4197: export 'PyInit___m2crypto' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib and object build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.exp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_AsStringAndSize referenced in function m2_PyString_AsStringAndSizeInt
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_FromStringAndSize referenced in function bn_to_mpi
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInt_AS_LONG referenced in function asn1_integer_set
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyBuffer_New referenced in function ec_key_get_public_der
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_AsFile referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_Check referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInstance_New referenced in function ssl_verify_callback
build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd : fatal error LNK1120: 7 unresolved externals
What's going on? I'm using Win64 OpenSSL v1.0.1e. Do I need older libraries?
from the full log it looks like one first problem is that the compiler can't find the python c header files. Then the linker can't find the python library. Perhaps the options to cl.exe are not good (shouldn't it be /ID:\... instead of -ID:\...?) or you don't have the python header files installed.
I'm using boost version 1.47, visual studio 2010, I downloaded the binaries for windows and linked to the include directory and lib directory from my project preferences. But I still can't use any ssl functionality from boost::asio.
This is the site where I downloaded the binaries: http://www.slproweb.com/products/Win32OpenSSL.html
I Downloaded: Visual C++ 2008 Redistributables and Win32 OpenSSL v1.0.1
These are the error messages I get:
Error 1 error LNK2019: unresolved external symbol _ERR_reason_error_string referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall boost::asio::error::detail::ssl_category::message(int)const " (?message#ssl_category#detail#error#asio#boost##UBE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\main.obj OmniTcp
Error 2 error LNK2001: unresolved external symbol _ERR_reason_error_string C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\OmniTcp.obj OmniTcp
Error 3 error LNK2019: unresolved external symbol _CRYPTO_set_id_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ) C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\main.obj OmniTcp
Error 4 error LNK2001: unresolved external symbol _CRYPTO_set_id_callback C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\OmniTcp.obj OmniTcp
Error 5 error LNK2019: unresolved external symbol _CRYPTO_set_locking_callback referenced in function "public: __thiscall boost::asio::ssl::detail::openssl_init_base::do_init::do_init(void)" (??0do_init#openssl_init_base#detail#ssl#asio#boost##QAE#XZ) C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\main.obj OmniTcp
Error 6 error LNK2001: unresolved external symbol _CRYPTO_set_locking_callback C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\OmniTcp\OmniTcp.obj OmniTcp
Error 25 error LNK1120: 12 unresolved externals C:\Documents and Settings\Elias\my documents\visual studio 2010\Projects\OmniTcp\Debug\OmniTcp.exe OmniTcp
I get a few more error messages but hey are all similar to eachother.
These are the libraries I linked to with boost 1.69, visual studio 2019, and OpenSSl-Win64:
libssl.lib;libcrypto.lib
As mentioned in the comments to the question, my project linked once I added:
lib\libeay32.lib
lib\ssleay32.lib
To the Project->Configuration Properties->Linker->Input->Additional Dependencies property.
Add the SSL dependencies (lib files) manually to project-->properties-->Linker-->Input-->Additional Dependencies.
As my hunt for a cross-platform framework/library went in progress, GLFW was mentioned many times. So, I decided to try it out. Now, it seems as though I can't even init a window. :-/
#include
#include
#include
int main(int argc, char *argv[])
{
int running = GL_TRUE;
srand(time(NULL));
if (!glfwInit())
exit(EXIT_FAILURE);
if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW))
{
glfwTerminate();
exit(EXIT_FAILURE);
}
while (running)
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(rand() % 255 + 1, rand() % 255 + 1, rand() % 255 + 1, 0);
glfwSwapBuffers();
running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED);
}
glfwTerminate();
exit(EXIT_SUCCESS);
}
I typed this in MVC++ 2010, linked the header, and 2 lib files (and it had 1 DLL file, so I threw that into the SysWOW64 folder), and I get these errors:
1>------ Build started: Project: glfwTest, Configuration: Debug Win32 ------
1> test.cpp
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(8): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>c:\users\andrew\documents\visual studio 2010\projects\glfwtest\glfwtest\test.cpp(22): warning C4244: 'argument' : conversion from 'int' to 'GLclampf', possible loss of data
1>test.obj : error LNK2019: unresolved external symbol __imp__glClearColor#16 referenced in function _main
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClearColor#16
1>test.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>GLFW.lib(window.obj) : error LNK2001: unresolved external symbol __imp__glClear#4
1>GLFW.lib(win32_window.obj) : error LNK2001: unresolved external symbol __imp__glClear#4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglGetProcAddress#4 referenced in function _initWGLExtensions
1>GLFW.lib(win32_glext.obj) : error LNK2001: unresolved external symbol __imp__wglGetProcAddress#4
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglMakeCurrent#8 referenced in function _createWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglCreateContext#4 referenced in function _createContext
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__wglDeleteContext#4 referenced in function _destroyWindow
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv#8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(win32_window.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv#8 referenced in function __glfwPlatformSetWindowSize
1>GLFW.lib(glext.obj) : error LNK2001: unresolved external symbol __imp__glGetIntegerv#8
1>GLFW.lib(glext.obj) : error LNK2019: unresolved external symbol __imp__glGetString#4 referenced in function __glfwParseGLVersion
1>c:\users\andrew\documents\visual studio 2010\Projects\glfwTest\Debug\glfwTest.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I understand the first few with the random colors, but the ones after that make no sense to me. Any idea what's wrong with this?
I'm pretty sure that I have linked the libs correctly. I place them into the
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib directory
and even linked them to my
C:\SDK\GLFW\glfw-2.7.bin.WIN32\lib-msvc100\debug directory.
The GLFW package was a .zip file, so I just extracted it to my default SDK folder (for all my APIs and other stuff). So the C:\SDK\GLFW is my default for GLFW.
You need to link to opengl32.lib.
For that, as pictured below, go to Project Setting and then Linker > input > Additional Dependencies and add opengl32.lib there (use ; to separate different libs).
Note that you don't actually need to have opengl32.lib file anywhere. Visual Studio knows where to find it.
Edit: I should note that you don't need to do anything except adding opengl32.lib. That other stuff is irrelevant. Additionally, if both are present, try swapping the order, which matters in some cases.