Hi I'm using openGL and doing a nehe tutorial but when I compile in visual studio 2015 I've got this error (sorry for the italian but I think it can be easily understood)
Gravità Codice Descrizione Progetto File Riga
Errore LNK1120 2 esterni non risolti lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\Debug\lesson7.exe 1
Errore LNK2019 riferimento al simbolo esterno _sscanf non risolto nella funzione _GetRegistrySysColors#8 lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\glaux.lib(tk.obj) 1
Errore LNK2019 riferimento al simbolo esterno _vsprintf non risolto nella funzione _PrintMessage lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\glaux.lib(tk.obj) 1
It works on VS2013 but if I run it on VS2015 it doesn't work.
Any idea? Thanks
Go to the properties of your project, Linker and Input, add in the Additional Dependencies this line : legacy_stdio_definitions.lib
#pragma comment(lib, "legacy_stdio_definitions.lib")
Add this line in your hfile like:
#include <XXXX.h>
...
#pragma comment(lib, "legacy_stdio_definitions.lib")
It's work for me
Related
I want to run the first test program for my software defined radio USRP X310 which is given on the company's website: https://kb.ettus.com/Getting_Started_with_UHD_and_C%2B%2B
I work with Visual Studio 2015 on Windows. I have installed, build and linked in VS2015 the boost and UHD libraries (UHD version 3.10.1.1 and boost version 1.63.0).
Trying to debug the program I get several error messages about 'unresolved external symbols'. I tried to locate the problem and ended up with very basic code example and noticed that the function 'uhd::usrp::multi_usrp::make(device_args)' does not work. In addition 'uhd::set_thread_priority_safe()' does not work either.
It seems to me that the code itself is not the problem. Does anyone know where these errors come from?
My code
#include <uhd/utils/safe_main.hpp>
`#include <uhd/usrp/multi_usrp.hpp>`
`#include <uhd/utils/thread_priority.hpp>`
`#include <csignal>`
`#include <iostream>`
int UHD_SAFE_MAIN(int argc, char *argv[]) {
uhd::set_thread_priority_safe();
std::string device_args("addr=192.168.10.2");
uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(device_args);
return 0;
}
Error messages (I am sorry that they are German. I translated them which is written in brackets):
Fehler (error) LNK2019 Verweis auf nicht aufgelöstes externes Symbol (link
to unresolved external symbol) ""__declspec(dllimport) public: __thiscall
uhd::device_addr_t::device_addr_t(class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??
0device_addr_t#uhd##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?
$allocator#D#2##std###Z)" in Funktion (in function) ""int __cdecl
_main(int,char * * const)" (?_main##YAHHQAPAD#Z)". line 1
Fehler (error) LNK2019 Verweis auf nicht aufgelöstes externes Symbol (link
to unresolved external symbol) ""__declspec(dllimport) public: __thiscall
uhd::device_addr_t::~device_addr_t(void)" (__imp_??
1device_addr_t#uhd##QAE#XZ)" in Funktion (in function) ""int __cdecl
_main(int,char * * const)" (?_main##YAHHQAPAD#Z)". line 1
Fehler (error) LNK2019 Verweis auf nicht aufgelöstes externes Symbol (link
to unresolved external symbol) ""__declspec(dllimport) public: static class
boost::shared_ptr<class uhd::usrp::multi_usrp> __cdecl
uhd::usrp::multi_usrp::make(class uhd::device_addr_t const &)" (__imp_?
make#multi_usrp#usrp#uhd##SA?AV?
$shared_ptr#Vmulti_usrp#usrp#uhd###boost##ABVdevice_addr_t#3##Z)" in
Funktion (in function) ""int __cdecl _main(int,char * * const)" (?
_main##YAHHQAPAD#Z)". line 1
Fehler (error) LNK2019 Verweis auf nicht aufgelöstes externes Symbol (link
to unresolved external symbol)""__declspec(dllimport) bool __cdecl
uhd::set_thread_priority_safe(float,bool)" (__imp_?
set_thread_priority_safe#uhd##YA_NM_N#Z)" in Funktion ""int __cdecl
_main(int,char * * const)" (?_main##YAHHQAPAD#Z)". line 1
LNK1120 4 nicht aufgelöste Externe (4 unresolved external symbols) line 1
this problem comes if you want to build it in Debug-Mode. The UHD you are linking to are build for Release-Mode, so you have to build your project in Release-Mode too. I had the same problem, and now i'm trying to build the UHD for VS2015 in Debug and Release mode, to be able to link in Debug-Mode, to the Debug-Objects and in Release-Mode to Release-Objects. But i don't get it build in Debug neither in Release-Mode with this TUT (https://kb.ettus.com/Building_and_Installing_the_USRP_Open_Source_Toolchain_(UHD_and_GNU_Radio)_on_Windows). I have to look for this. IF you will get it to work, it would be nice if you can tell how you have done it ( I'm german too).
Hope this helps you, even your post is 6 months old :D.
I try to use dlib in Qt project on Windows. After downloading I at once started to try build my Qt application, without building examples. I also downloaded static libraries libpng and libjpeg from GnuWin.
.pro file:
SOURCES += main.cpp\
mainwindow.cpp \
C:/Users/user/Downloads/dlib-19.0/dlib-19.0/dlib/all/source.cpp
HEADERS += mainwindow.h
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0"
LIBS += -L"C:\Users\user\Downloads\dlib-19.0\dlib-19.0"
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\external\libpng"
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\external\libjpeg"
LIBS += -L"C:\Users\user\Downloads\jpeg-6b-4-lib\lib" -ljpeg
LIBS += -L"C:\Users\user\Downloads\libpng-1.2.37-lib\lib" -lpng
LIBS += -lwinmm -lws2_32 -luser32 -lgdi32 -lcomctl32 -limm32
QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT
Code:
try
{
array2d<rgb_pixel> img;
load_image(img, "C:\\Users\\user\\Downloads\\test.jpg");
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
MinGW output:
png_loader.cpp:103: undefined reference to 'png_set_longjmp_fn'
png_loader.cpp:153: undefined reference to 'png_set_longjmp_fn'
save_png.cpp:20: undefined reference to 'png_set_longjmp_fn'
save_png.cpp:72: undefined reference to 'png_set_longjmp_fn'
I know that I need to use libpng 1.4, but I can't find this version in GnuWin, so I used the most relevant 1.2.
MSVC runtime exception:
exception thrown!
Unable to load image in file C:\Users\user\Downloads\test.jpg.
You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG
files.
Do this by following the instructions at http://dlib.net/compile.html.
Note that you must cause DLIB_JPEG_SUPPORT to be defined for your
entire project.
So don't #define it in one file. Instead, add it to the
C/C++->Preprocessor->Preprocessor Definitions
field in Visual Studio's Property Pages window so it takes effect for
your entire application.
But I set -DDLIB_JPEG_SUPPORT in my .pro file, linked with jpeg and png and even downloaded in the working folder shared library jpeg.dll.
How can I solve this probles or how can I use dlib in Qt on Windows?
UPD:
Errors after E:\CMake\bin\cmake.exe --build . --config Release:
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\3d_point_cloud_ex.vcxproj" (default target)
(3) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj" (default target) (4
) ->
(target ClCompile) ->
f:\gstreamer\1.0\x86\include\jmorecfg.h(211): error C2371: 'boolean': redefinition; different basic types [C:\Users\user
\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\basetsd.h(72): error C2371: 'INT32': redefinition; different b
asic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
c:\program files (x86)\windows kits\8.1\include\shared\rpcndr.h(178): error C2371: 'boolean': redefinition; different
basic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
c:\program files (x86)\windows kits\8.1\include\shared\wtypesbase.h(493): error C2371: 'BOOLEAN': redefinition; diffe
rent basic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
UPD2:
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\3d_point_cloud_ex.vcxproj" (default target) (3) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj" (default target) (4) ->
(target ClCompile) ->
C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\image_loader\jpeg_loader.cpp(17): fatal error C1083: Cannot open include file: 'jpeglib.h': No such file or directory [C:\U
sers\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\image_saver\save_jpeg.cpp(16): fatal error C1083: Cannot open include file: 'jpeglib.h': No such file or directory [C:\User
s\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
UPD3:
.pro file:
INCLUDEPATH += "E:\dlib_build\include"
LIBS += -L"E:\dlib_build"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT
MSVC 2015 64bit Release output:
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2(void)" (??0entrop...
mainwindow.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2(void)" (...
mainwindow.obj : error LNK2019: unresolved external symbol "public: void __cdecl dlib::entropy_decoder_kernel_2::set_stream(class std::basic_istream<c...
mainwindow.obj : error LNK2019: unresolved external symbol "public: void __cdecl dlib::entropy_decoder_kernel_2::decode(unsigned int,unsigned int)" (?...
mainwindow.obj : error LNK2019: unresolved external symbol "public: unsigned int __cdecl dlib::entropy_decoder_kernel_2::get_target(unsigned int)" (?g...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::png_loader::png_loader(class std::basic_string<char,struct std::char...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::png_loader::~png_loader(void)" (??1png_loader#dlib##QEAA#XZ) referen...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_gray(void)const " (?is_gray#png_loader#dlib##QEB...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_graya(void)const " (?is_graya#png_loader#dlib##Q...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_rgb(void)const " (?is_rgb#png_loader#dlib##QEBA_...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_rgba(void)const " (?is_rgba#png_loader#dlib##QEB...
mainwindow.obj : error LNK2019: unresolved external symbol "private: unsigned char const * __cdecl dlib::png_loader::get_row(unsigned int)const " (?ge...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::jpeg_loader::jpeg_loader(class std::basic_string<char,struct std::ch...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::jpeg_loader::is_gray(void)const " (?is_gray#jpeg_loader#dlib##Q...
mainwindow.obj : error LNK2019: unresolved external symbol USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSER...
E:\dlib_build\lib\dlib.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
release\dlibWindows.exe : fatal error LNK1120: 15 unresolved externals
jom: F:\Projects\QtProjects\build-dlibWindows-Desktop_Qt_5_6_0_MSVC2015_64bit-Release\Makefile.Release [release\dlibWindows.exe] Error 1120
UPD4:
.pro file:
INCLUDEPATH += "E:\dlib_build\include"
LIBS += -L"E:\dlib_build"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
Code:
try
{
//or even just one line "frontal_face_detector detector = get_frontal_face_detector();"
array2d<rgb_pixel> img;
load_image(img, "C:/Users/user/Downloads/test.jpg");
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
Release output:
Exited with code 255
You have chosen the way of compiling by incliding all/source.cpp into your project. This is possible but I think not the best way how to use dlib.
So if you want to use all/source.cpp in your project - please follow instructions from here: http://dlib.net/compile.html
Compiling on Windows Using Visual Studio
All you need to do is create an empty console project. Then add dlib/all/source.cpp to it and add the folder containing the dlib folder to the #include search path. Then you can compile any example program by adding it to your project.
Again, note that dlib will only be able to work with jpeg and png files if you link in libjpeg and libpng. In Visual Studio, the easiest way to do this is to add all the source files in the dlib/external folder into your project and also define the DLIB_PNG_SUPPORT and DLIB_JPEG_SUPPORT preprocessor directives. If you don't know how to configure Visual Studio then you should use CMake as shown above since it will take care of everything automatically.
And with adding dlib/external folder - you can remove libjpeg and libpng from your project.
But as I said - its not the best way how to compile dlib. Dlib is designed to be used with CMAKE and the best way is to build it with CMAKE.
Why this way is better:
no need to rebuild dlib every time your project changes
possible use of CUDA code (not now - but a bit later when CUDA 8 and VS update 4 will be released)
Here the first step (after installing CMAKE) should be checking if Dlib works. According to Dlib's instructions best way is to build examples and run them (from dlib's folder):
cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
When running cmake .. you can specify your compiler version, for example:
cmake .. -G"Visual Studio 14 2015 Win64"
To build examples with Visual Studio 2015 x64
After testing examples its a good time to build Dlib and start using it in real projects. And yes, again build is done by CMAKE (from dlib folder):
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=C:\Users\user\dlib
cmake --build . --config Release --target install
The building process is little different from building examples:
CMAKE_INSTALL_PREFIX=C:\Users\user\dlib - compiled dlib will be installed into C:\Users\user\dlib
--target install means we are installing dlib
After the building process will be finished - you are free to use dlib.lib (static version of Dlib) from C:\Users\user\dlib\lib. If you will use CMAKE with your project - you will need to add -DCMAKE_PREFIX_PATH=c:\Users\user\dlib. But now you are trying to compile with Qt Creator (QMake). Here is your .pro file should look like (the minimal possible example):
SOURCES += face_detection_ex.cpp
INCLUDEPATH += "C:\Users\user\dlib\include"
LIBS += -L"C:\Users\user\dlib"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
This project will not compile and run in Debug mode build because we used --config Release in our building process. But Release mode will run very fast
Please note
Visual Studio will need separate dlib installation for Release and Debug builds. And Debug build of Dlib will be extremely slow
Adding /arch:AVX to compiler flags (MSVC) will make Dlib run much faster
DNN module will not work under MSVC until Cuda 8 and MSVC 2015 update 4 will be released
I tried to build my app that uses glib-2.0 with Visual Studio.
The glib-2.0 was installed with pacman from msys2, so I haven't got glib-2.0.lib but I have glib-2.0.a
When I set glib-2.0.a and intl.a in Additional Dependencies from Visual Studio 2013, I got this errors:
Erreur 2 error LNK2001: symbole externe non résolu ___chkstk_ms C:\Users\julien\Documents\Visual Studio 2013\Projects\m\m\libintl.a(loadmsgcat.o) m
Erreur 66 error LNK2001: symbole externe non résolu __imp_getsockopt C:\Users\julien\Documents\Visual Studio 2013\Projects\m\m\libglib-2.0.a(giowin32.o) m
etc etc ...
I have set intl.a too because pkg-config --libs glib-2.0 --msvc-syntax returns:
/libpath:C:/msys64/mingw64/lib.lib glib-2.0.lib intl.lib
What I have to do to build my app?
You need to build GLIB with MSVC.
I'm developing on a visual studio 2013 application and therefore I need to include openssl libraries.
What have I done so far:
I downloaded the precompiled openssl libraries for VS2013 openssl-1.0.1l-vs2013.7z from here: http://www.npcglib.org/~stathis/blog/precompiled-openssl/ (newest stable entry MSVC2013)
included openssl's include dir to C/C++/General/Additional Include Directories
added lib64/libeay32MTd.lib and lib64/ssleay32MTd.lib to Linker/Input/Additional Dependencies
I call openssl headers this way: #include <openssl\pem.h> (as example)
I am using VS 2013 on a 64 Bit Windows maschine with the multithreading runtime library (/MTd). Every time I want to build my project it gives me the following errors:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_BIO_new_mem_buf" in Funktion "__catch$?decrypt#cipherEngine##QAE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PADH#Z$4".
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_RSA_private_decrypt" in Funktion "__catch$?decrypt#cipherEngine##QAE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PADH#Z$4".
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_PEM_read_bio_RSAPrivateKey" in Funktion "__catch$?decrypt#cipherEngine##QAE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PADH#Z$4".
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: class std::basic_string,class std::allocator > __thiscall cipherEngine::rsaPrivateDecrypt(class std::basic_string,class std::allocator >)" (?rsaPrivateDecrypt#cipherEngine##QAE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V23##Z)" in Funktion ""public: bool __thiscall cipherEngine::alterKey(class std::basic_string,class std::allocator >)" (?alterKey#cipherEngine##QAE_NV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)".
fatal error LNK1120: 4 nicht aufgelöste Externe
Anyone who knows the "missing link"?
When adding external libraries to VS I usually try to include the library source and build them within my own tree. This avoids the problem I think you are seeing, which is that the precompiled library has been compiled with slightly different options than your main project. The different options render the library unusable to you.
If you really don't want to compile the lib within your project, try investigating those symbols further to identify the compile variant.
I forgot to define the class, the function rsaPrivateDecrypt belongs to (shame on me). The second thing was to use the 32Bit libs instead of the 64Bit libs.
I'm trying to compile the example from here;
http://msdn.microsoft.com/en-us/library/ms682619(VS.85).aspx
I've installed the Platform SDK, but I'm getting these errors;
Error 1 error LNK2019: unresolved external symbol _GetDeviceDriverBaseNameW#12 referenced in function _main DriverChecker.obj DriverChecker
Error 2 error LNK2019: unresolved external symbol _EnumDeviceDrivers#12 referenced in function _main DriverChecker.obj DriverChecker
Error 3 fatal error LNK1120: 2 unresolved externals C:\Files\Projects\VS2008\DriverChecker\Debug\DriverChecker.exe DriverChecker
Anyone any idea how to get this compiling correctly?
You just need to add psapi.lib as an additional library in your linker options.
Edit properties for your project, navigate to Linker->Input, and type "psapi.lib" where it says Additional Dependencies.