how to compile pymqe.c for Python3? - python-3.x

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?

Related

Linking Error C++

I am getting the following error during linking c++ code with MS VC 6:
Creating library Debug/RATPSS.lib and object Debug/RATPSS.exp
LINK : warning LNK4098: defaultlib "MSVCRTD" conflicts with use of other libs; use /NODEFAULTLIB:library
CDispatchFailurePssData.obj : error LNK2001: unresolved external symbol "class ostream_withassign cout" (?cout##3Vostream_withassign##A)
CNormalAccPssData.obj : error LNK2001: unresolved external symbol "class ostream_withassign cout" (?cout##3Vostream_withassign##A)
CNormalPssData.obj : error LNK2001: unresolved external symbol "class ostream_withassign cout" (?cout##3Vostream_withassign##A)
Debug/RATPSS.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Other thirdparty softwares used: Rouguewave 4,orbix 5.1 .
Please suggest the possible solution approach.
I think there is a problem of the properties of the project that are dependent on each other.
Probably change the property would fix the problem.
See here /NODEFAULTLIB (Ignore Libraries) and change the property according to your requirment.

How to use libgit2 from a native C++ application on Windows? (Microsoft VC++)

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.

SFML linker problems on eclipse VC++

I am trying to use the SFML library for audio in my project.
I am developing in eclipse juno for c++ and am using SFML v1.6.
I added sfml-audio-d.lib, sfml-main-d.lib, and sfml-system-d.lib into
C/C++ General > paths and symbols>libraries
I also defined a macro named SFML_DYNAMIC into
C/C++ Build>Settings>C++ Compiler>Preprocessor 'Defines /D' section
I added the directory that contains all the dlls into the PATH environment variable.
In my code I make use of sf::SoundBuffer, but when I try to build the project I get the following linker error:
Chunk.obj : error LNK2001: unresolved external symbol "private: static class sf::SoundBuffer * Chunk::breakBlockSound" (?breakBlockSound#Chunk##0PAVSoundBuffer#sf##A)
MyProject.exe : fatal error LNK1120: 1 unresolved externals
Had to rebuild the project in VS2010 before using it. Works now.

Linker with user32.lib

I am trying to create a windows application but am getting a linker error as follows:
1>test_project.obj : error LNK2019: unresolved external symbol "int __cdecl run(void)" (?run##YAHXZ) referenced in function _WinMain#16
I assume this is because user32.lib is not linking correctly, but I have added it to linker->input->additional dependencies and added the directory containing it to library directories. Help would be appreciated.
I don't think this has anything to do with user32.lib. Most likely your program contains a forward declaration of function int run(void); which you never define yet trying to call from your WinMain(...) procedure.

Library linker errors driving me mad

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

Resources