so I'm using visual studio 2019 and I installed pthread package but whenever I run my code the following error pops up "'timespec': 'struct' type redefinition "
the most common solution I found is to put #define HAVE_STRUCT_TIMESPEC before including pthread.h but whenever I do so two errors occur:
1- LNK2019 unresolved external symbol __imp__pthread_create referenced in function _main
2- 1 unroslved externals
I know this problem is common but I didn't find any solution to the two new errors specified.
Related
Trying to compile a VC++ DLL I get some error messages related to Visual Studio cannot resolve external symbols, errors LNK2001, LNK1120.
In my case the symbol it cannot be resolved is: __imp__BCryptGenRandom#16
and the error message is:
error LNK2001: unresolved external symbol __imp__BCryptGenRandom#16
I have googled and found that it is said to link BCrypt.lib so I have linked it at "properties->linker->input->additional dependency"
Also at ""properties->linker->all options->additional library directoris" I have added below one where BCrypt.lib is for x86:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\um\x86
And finally at "properties->linker->General->Use library dependencies inputs" I have set "Yes".
But none of these methods work.
I managed to process module pymqe.c into pymqe.pyd for Python2 using VC 2017 compiler and my own make file. Unfortunately, it doesn’t work for Python3. If I try compile module pymqe.c from pymqi-1.9.3.tar.gz in the same way, the linking step fails with the error message:
LINK : error LNK2001: unresolved external symbol initpymq
pymqe.lib : fatal error LNK1120: 1 unresolved externals
My make file contains the following instruction to link pymqe.c with the resulting library pymqe.pyd:
/EXPORT:initpymqe pymqe.obj
I assume, the function initpymqe is excluded during compilation for Python3 due to pre-compiler instruction in the source code of the module pymqe.c:
#if PY_MAJOR_VERSION==2
void initpymqe(void) {
…
#else
Does anyone know, how to handle this problem?
Summary: Is there any tiny example on how to build the Win32 C++ console application that uses the libgit2 library (sources available at GitHub)?
I have followed the readme and the wiki on how to build the library on Windows using the CMake, and it worked smoothly (only a single unit-test error).
Now, I want to build a simple console application that uses the library -- using Microsoft Visual Studio C++ 2010 (the.vcxproj and the.sln). I have found the general.c code in the libgit2 examples, and I would like to do the same from my C++ application. No success -- I feel really stupid today...
I have noticed there is libqgit2 for C++ and Qt. Is there anything similar for pure C++? Or is there a way to use the C library from C++ application?
Update: I have renamed the general.c to general.cpp, added the libgit2 include path to the project and the path to the .lib files, changed the #include <stdio.h> to #include <cstdio>, and compiled. The following link errors appear:
1>------ Build started: Project: libgit2_general, Configuration: Debug Win32 ------
1>general.obj : error LNK2019: unresolved external symbol _git_repository_free referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_get_string referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_get_int32 referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_config_open_ondisk referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _git_strarray_free referenced in function _main
... etc.
1>general.obj : error LNK2019: unresolved external symbol _git_repository_open referenced in function _main
1>general.obj : error LNK2019: unresolved external symbol _giterr_last referenced in function "void __cdecl check_error(int,char const *)" (?check_error##YAXHPBD#Z)
1>D:\Tutorial\libgit2_general\Debug\libgit2_general.exe : fatal error LNK1120: 56 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
This strongly suggests a calling convention mismatch to me. libgit2 uses __stdcall by default, for a number of reasons, while Visual Studio defaults to creating projects that use the __cdecl calling convention. While your program can use either calling convention and successfully call libgit2 using a different one, the easiest solution is probably just to use the same calling convention for both.
When you configure libgit2, you can turn off the STDCALL flag, which will cause it to emit a library built with __cdecl calling conventions:
cmake %PATH_TO_LIBGIT2_SOURCE% -DTHREADSAFE=ON -DSTDCALL=OFF
cmake --build .
It's a little surprising if you generated the project from CMake, bit it could be that you're not linking to libgit2.lib. Make sure you have git2.dll in Project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.
I am struggling for hours to build my first Allegro 5 application in Visual Studio 2012, using Windows 7 x64.
I have followed all the steps of this tutorial: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2010_and_Allegro_5#Download which means that the Allegro directory is in c:/allegro/ and all the libraries are added in both the debug and release configurations.
I also changed my subsystem to Windows, so now it says "Windows (/SUBSYSTEM:WINDOWS)"
1>------ Build started: Project: AllegroTesting, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol __imp__al_install_system referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_rest referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_map_rgb referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_create_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_destroy_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_flip_display referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__al_clear_to_color referenced in function _main
1>c:\users\skypower\documents\visual studio 2012\Projects\AllegroTesting\Debug\AllegroTesting.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
For anyone wondering, the issue was resolved for skypower in this thread on the allegro.cc forums: Problem installing allegro 5 on vs 2012
It boiled down to specifying the wrong linker input libraries when following the Visual Studio 2010 setup instructions on the relevant Allegro.cc wiki page. Make sure to type the actual version of Allegro instead of typing 5.0.x (i.e. the x should be replaced with the minor version, which is currently 8, so type the version of 5.0.8).
(some extra context if you read that original thread - the x I'm referring was previously a ? in the wiki page's setup instructions)
I struggled with this problem for a long time,pulled half my hair off,and then i finally tried something. I'm using Windows 8 and VS2012 and Allegro 4.2 cause I got it right using the older version.
Link to get the 4.2 binary => http://en.sourceforge.jp/projects/sfnet_alleg/downloads/allegro-bin/4.2.0/allegro-msvc6-4.2.0.zip/
Once you unpack it, there'll be 4 files => bin,include,lib and the readme file.
Copy the include and lib files in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
Fire up VS and create a Win32 Project,the when prompted with Application setting,check Empty project and click OK.
Insert a source file in and paste this code =>
#include <allegro.h>
int main(void) {
allegro_init();
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
install_keyboard();
textout_ex(screen, font, "Hello World!", 1, 1, 10, -1);
textout_ex(screen, font, "Press ESCape to quit.", 1, 12, 11, -1);
while(!key[KEY_ESC]);
allegro_exit();
return 0;
}
END_OF_MAIN()
Now right click on the project in the solution explorer->properties->Linker->Input->Additional Dependencies. Click on it reveal the drop down menu->edit and in the blank space at the top enter 'alleg.lib' ->OK->OK.
Now copy the 3 dll files in the bin folder from the unpacked Allegro 4.2 folder.
Go to where you saved your project, default is my documents->visual studio 2012->projects. go into the folder with your project name->Debug folder. here you will find the .exe file for your project. paste the dll files here.
go to VS2012. press f7 to compile your program,should be no errors. press ctrl+f5 to run.
10.you get a black window saying hello and press esc to exit. That's it! :D
It's me again. I'm back with an all new project and an all new problem.
I am trying to implement something for Growl. Either using a static or shared library (both are provided). I included the necessary header and linked to the library. (2 ways actually, once through the project properties and the other through a pragma statement). However, im still receiving the following linker errors:
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall Growl::Growl(enum Growl_Protocol,char const * const,char const * const,char const * * const,int)" (__imp_??0Growl##QAE#W4Growl_Protocol##QBD1QAPBDH#Z)
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall Growl::~Growl(void)" (__imp_??1Growl##QAE#XZ)
fatal error LNK1120: 2 unresolved externals
The line of code that is causing these linker errors is this line:
const char *n[2] = { "username" , "password" };
Growl *growl = new Growl(GROWL_TCP,NULL, "Appname", (const char **const)n,2);
The header file is being included at the top of the file and I am linking with the following line:
#include "..\\..\\..\\libs\\Growl\\growl++.hpp"
#pragma comment(lib, "..\\..\\..\\libs\\Growl\\libgrowl-static++.lib")
The header source can be found here:
https://github.com/psinnott/gntp-send/blob/master/headers/growl%2B%2B.hpp
I retrieved the pre-built binaries from the following page:
https://github.com/psinnott/gntp-send/wiki/Windows
Some extra info: I do have my Project Propeties character set to use Multi-Byte Character Set, im under the assumption this shouldn't affect anything. This is also a Win32 Console application.
Where am I going wrong?
Update:
Found this via google:
http://groups.google.com/group/growl-for-windows/browse_thread/thread/6c48a62454d062f1
Followed the instructions:
Added the libgrowlstatic.lib (alongside libgrowlstatic++.lib)
Added the pre-processor definitions, GROWL_STATIC and GROWL_CPP_STATIC
Got lots of error including:
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
fatal error LNK1169: one or more multiply defined symbols found
So I added the following line to Project properties, Linker, Command Line:
/NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:LIBCMT
Now im getting alot more errors including some of the following:
libgrowl-static.lib(tcp.obj) : error LNK2019: unresolved external symbol _atoi referenced in function _growl_tcp_parse_hostname
libgrowl-static.lib(tcp.obj) : error LNK2019: unresolved external symbol _strchr referenced in function _growl_tcp_parse_hostname
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _fseek referenced in function _growl_tcp_register
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _fopen referenced in function _growl_tcp_register
libgrowl-static.lib(growl-static.obj) : error LNK2019: unresolved external symbol _strcpy referenced in function _growl_udp_notify
Been at this for several hours and can't seem to figure it out. 10+ views and no replies?
I swear im not being lazy. I looked into one of the answers provided about libraries but didn't have much luck. Nothing explained why this is acting the way it is. Please help!
#pragma comment(lib, "..\\..\\..\\libs\\Growl\\libgrowl-static++.lib")
There is a clear mismatch between the #pragma and the way your code is getting compiled. The name of the library strongly suggests this is a static link library, the "static" in the name makes that clear. The error messages however talk about __declspec(dllimport), a directive that's used when you compile code that #includes a header that assumes the code lives in a DLL instead of a static link library.
The other errors you are getting bear this out as well. The Project + Properties, C/C++, Code Generation, Runtime Library setting matters. You are using the /MD setting, a setting that's appropriate when you work with DLLs. The library no doubt was compiled with /MT, a setting appropriate when you create a monolithic EXE that doesn't use DLLs. You are trying to link two chunks of code that were built with conflicting settings, the linker falls over when trying to deal with this. It explicitly says so in an error message.
You'll need to either dig up the DLL version of the .lib or use /MT consistently in the rest of your code. There's usually a #define that tells the .h file which version of the .lib you intend to link.
This is working for me. It assumes you want to use the static libraries and not the dll.
Properties -> Configuration -> Properties -> VC++ Directories
Add directory of unzipped sdk to include and library directories
Properties -> Configuration -> Properties -> C/C++ -> Preprocessor
Add GROWL_STATIC and GROWL_CPP_STATIC to preprocessor definitions
Properties -> Configuration -> Properties -> C/C++ -> Code generation
Change runtime library to multi threaded ( /MT or /MTd )
Properties -> Configuration -> Properties -> Linker -> Input
Add ws2_32.lib , libgrowl-static.lib and libgrowl-static++.lib to additional dependencies