windows library for _chkstk_ms() function - c

I have one windows project built in VS 2015 in windows7. Now I have to use one third party library (implemented in C) built in Mingw - 64 bit (for windows). When I try to link this library I am getting one compilation error :--
Unresolved external symbol __chkstk_ms.
Now I have resolved this issue by linking 2 more libs - libgcc.a and libssp.a.
But after, that when I run my application, I have started getting memory exception in some routines which was working fine previously.
I have doubt I should not solve this compilation error by using these 2 libraries (as these are not windows). Instead of it, there should be some windows / VC run time library which should be providing implementation of this routine.
Can someone please suggest right way to resolve this linking error.

Related

Compiling specific apache module in VS2010

Over the last few days I've been tinkering with mod_pLua on Windows (https://sourceforge.net/projects/modplua/ or https://github.com/Humbedooh/mod_pLua).
The pre-built Windows binary works a treat, except it doesn't seem to have been compiled with mod_dbd support for database connectivity. The documentation suggests that to enable this feature you must compile with a certain tag, so I've been trying to compile the module in VS2010 - hoping that I'll be able to get mod_dbd support working at some point - but I've run in to a snag. It just will not compile.
What I've done so far:
Included apache/include and apache/lib, which got rid of a lot of
errors
Included lauxlib.h, lua.h, luaconf.h and lualib.h from Lua 5.2, which got rid of a lot of errors
Compiled a .lib file from Lua 5.2 sources and included it, which fixed a few errors
The errors I'm getting at the moment are:
error LNK2019: unresolved external symbol _luaL_openlib referenced in function _lua_dbopen C:\Users\Michael\Desktop\Projects\C\mod_plua\mod_plua.obj
And a plethora like this:
IntelliSense: a value of type "const char ()(cmd_parms *cmd, void *cfg, const char *arg)" cannot be used to initialize an entity of type "cmd_func" c:\users\michael\desktop\projects\c\mod_plua\mod_plua.h 394 5
As I'm not a C/C++ native, I only have a vague idea of what's wrong, and have likely done something wrong in my attempts to fix the issue. If someone could guide me in the right direction (or better yet, write a little instructional on how to compile the module from start to finish) I would be so happy.
I've uploaded my VS2010 project files and source here: https://dl.dropboxusercontent.com/u/51243175/mod_plua_vs2010.7z
Self-answer:
The primary reason for the failure to compile was the Lua .lib file. The Microsoft compiler does strange things when dealing with C code, so I got an appropriately compiled version of the .lib from the LuaBinaries SourceForge repository (http://sourceforge.net/projects/luabinaries/) - specifically, 5.2.3/Windows Libraries/Dynamic/lua-5.2.3_Win32_dll10_lib.zip (which is compiled for VS2010).
This didn't enable mod_dbd support, which requires headers and sources from the Apache APR project, but it did allow successful compilation.
You should not be using mod_pLua really, I haven't worked on that for nearly 3 years ;) You should use mod_lua instead, which comes bundled with httpd and works pretty much the same way (although it does not support the php-like scripting that mod_pLua does)
For DBD specific setups (especially how to use it on Windows), see http://modlua.org/api/database

When I try to run MPI code, I get undefined reference to MPI_File_Seek#12, What might be the reason?

I've been trying to run the code from https://github.com/dungtn/mpi-floyd/blob/master/floyd2d.c in my system. I'm using CodeBlocks IDE and MS-Mpi. When I try to compile the code, it says undefined reference to MPI_file_seek#12. Does this mean MS mpi does not support this function or why does this happen?
This usually happens if you are trying to link 32-bit code with 64-bit libraries. The fact that the unresolved symbol has #12 in its name means that the compiler is expecting that MPI_File_seek is an stdcall function. stdcall is mainly used for DLL functions and only on x86 (x64 uses a different calling convention similar to fastcall). If you are linking against the 64-bit import library of MS-MPI, the decorated symbol won't be found in the library and such an error will occur.
Double check what version of MS-MPI you have and also your project settings and make sure that both have the same "bitness".
Change the project settings in Code::Blocks to a C project (rather than C++ project, what you have currently). It may be easier to create a brand new C project and import the file there. Double check that Code::Blocks in running gcc and not g++ to compile your code (floyd2d.c).
If it still doesn't work, please post the full compiler and linker output of Code::Blocks, including the commands run and their output messages.

An odd linkage diffrence between Debug and Release resulting an unresolved _except_handler3, or Why, oh, why I don't know about libcmtd?

A windows application I've been working on, is due to delivred without the use of CRT.
There's a few good articles descirbing the guidlines and benefits of doing so (none of which I could find upon writing this question - sorry) . Other then not using CRT symbols explicitly, it's all about linker and compailer configuration. My Release and Debug configurations are nearly identical now , and both specify /NODEFAULTLIB:"LIBCMT" only diffrence is the Run time flag /MT (in Release) vs. /MTd (in Debug) - that is required as I'm using __try/__except syntax for SEH, and so the only needed function is _except_handler3(). However, the Debug version is beeing built successfully, and the Release version fail with Unresolved Symbol _except_handler3 linkage error. When forcing Release version to compile with /MTd - this issue is solved.
How is that possible? which .lib contains the _except_handler3 export? and how can I solve this?
For an application without CRT see: http://blog.kalmbach-software.de/2008/02/02/smallest-application-size-for-win32-console-application/
But if you want to use __try / __except you need to use the CRT; or you need to write your own "_except_handler3".
See also: _except_handler3
Also you have the CRT source, and you can take a look into the source, to see what it is doing!
See: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src

Linking a static library to an Apache module

I am experimenting with Apache module development and therefore I'd like to know how to link a static library to a module (if it is even possible).
Naturally it compiles and installs nicely and Apache fails when the module is loaded. The message is:
Cannot load /usr/lib/apache2/modules/mod_example.so into server: /usr/lib/apache2/modules/mod_example.so: undefined symbol: zmq_socket
The library I want to link is zeromq, I am using the makefile generated by apxs2. Here I added -lzmq. If I remove zmq related code, the module runs fine.
My platform is Ubuntu 12.04 64 bit, gcc4.6.3.
well, apparently the generated makefile is not a good idea. I replaced the makefile references with basic compilation commands, e.g.:
apxs2 -c -lzmq mod_example.c
alk's suggestion in the comment of the question would also work (adding library location to LD_LIBRARY_PATH), since I was linking another apache-related library (apreq), which linked without any problems.

Unable to load shared library: undefined symbols

I have my own program with plugins (dynamic shared libraries) on a linux (ubuntu) system. My libraries (plugins) use OpenCV (maybe not so important).
My plugins are in /usr/local/lib/mysoft/.
I have compiled my program successfully even with libraries, successfully installed so everything seems to be OK up to this point.
When I run my program, it loads a bunch of these libraries based on some configuration file. I have several libraries which are loaded successfully but I cannot load one library. It gives me error when loading (used dlopen() to open the library):
/usr/local/lib/mysoft/libMyPlugin2.so: undefined symbol: _ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi
Segmentation fault (core dumped)
Tue Nov 20 19:11:29 CET 2012
It obviously has some problems to find cv::resize which is part of OpenCV but I don't understand why.
I checked following things:
OpenCV is probably correctly installed since other libraries use it as well and are loaded without problems
no dependencies of my program, libMyPlugin2.so or OpenCV are missing (checked with ldd)
Architecture of all libraries and binaries seems to be the same (I checked it with objdump -f)
Does anybody have an idea what am I doing wrong?
This post seems to be so relevant but still didn't help:
Linux shared library that uses a shared library undefined symbol
Well I found the problem, hopefully it can help others...
The problem - I was missing one OpenCV library when compiling. So I replaced "opencv_core opencv_highgui" by "opencv_core opencv_imgproc opencv_highgui" and everything works.
So although I was able to compile it one of the dependencies was missing - I guess something has changed in OpenCV cause these sources worked perfectly (even with build) with older versions of the OpenCV.

Resources