I am developing a project which uses third party dlls and libraries. I want to build my project using static CRT (LIBCMTD) as I wish to run my application in "IBM purifier". However, the third party libraries are built using dynamic CRT(MSVCRT).
This gives linking error as:
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __mktime64 already defined in LIBCMTD.lib(mktime64.obj) MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __gmtime64 already defined in LIBCMTD.lib(gmtime64.obj) MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __localtime64 already defined in LIBCMTD.lib(loctim64.obj)
I have tried various linker settings. Also I gave /FORCE:MULTIPLE to the linker command line to ignore the multiple definitions and create a build. It did so, but my application stil not could run in purifier.
Is there a good way to do what I'm trying to achieve? I have no control over the 3rd party source code to control their settings.
Thanks
If it needs to be built using only the static library, you're probably hosed -- their DLL is already configured to link to the standard library dynamically, and nothing you do in building the rest of the project is going to change that (unless you can get that vendor to supply a version that links to the standard library statically).
Related
I am trying to write a Xamarin Android binding library for a library that is loaded in the app during runtime. When using this library in a normal Android project, you would use "compileOnly".
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
From my understanding, "compileOnly" makes the code from the library available for compilation but does not add it to the resulting apk. Meaning it needs to be provided in runtime for the app to work.
When reading the Xamarin binding Build Action docs, "compileOnly" sounds very similar to "InputJar".
Does not embed the .jar into the resulting Bindings Library .DLL. Your Bindings Library .DLL will have a dependency on this .jar at runtime. Use this option when you do not want to include the .jar in your Bindings Library (for example, for licensing reasons). If you use this option, you must ensure that the input .jar is available on the device that runs your app.
However, when compiling my application while using methods provided by the runtime library, I get errors from the generated java code that the packages do not exist.
javac.exe error : error: package de.robv.android.xposed does not exist
javac.exe error : de.robv.android.xposed.IXposedHookLoadPackage
javac.exe error : error: package de.robv.android.xposed.callbacks.XC_LoadPackage does not exist
javac.exe error : public void handleLoadPackage (de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam p0)
error : error: package de.robv.android.xposed.callbacks.XC_LoadPackage does not exist
error : private native void n_handleLoadPackage (de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam p0);
Meaning that the code was not made available during compilation. How can I make sure the code is made available during compilation but not embedded into application?
See my answer at https://stackoverflow.com/a/64973909/4374462
Either using AndroidExternalJavaLibrary or [assembly: Java.Interop.DoNotPackage("ref.jar")].
I've post this issue 3weeks ago,
And I now post it again.
I use 3rd party library in my project.
Boost C++ Library.
only circular_buffer.hpp header file make trouble.
I don't know what means error message.
so, I post error logs today.
===================environment
My mac os 10.11 version
Xcode version 7.1.1(7B1005)
C++ Language Dialect : c++11[-std=c++11]
C++ Standard Library : libc++(LLVM C++ standard library with C++11 support)
====================error logs
/Users/genosyde/Downloads/Coding/ofFrameWork/of_v0.9.4_osx_release/addons/ofxOSXBoost-master/libs/boost/include/boost/circular_buffer.hpp:39:27: No member named 'remove_pointer' in namespace 'boost::move_detail'
/Users/genosyde/Downloads/Coding/ofFrameWork/of_v0.9.4_osx_release/addons/ofxOSXBoost-master/libs/boost/include/boost/circular_buffer.hpp:40:27: No member named 'add_pointer' in namespace 'boost::move_detail'
/Users/genosyde/Downloads/Coding/ofFrameWork/of_v0.9.4_osx_release/addons/ofxOSXBoost-master/libs/boost/include/boost/circular_buffer.hpp:45:7: No member named 'disable_if_c' in namespace 'boost::move_detail'; did you mean '::boost::disable_if_c'?
/Users/genosyde/Downloads/Coding/ofFrameWork/of_v0.9.4_osx_release/addons/ofxOSXBoost-master/libs/boost/include/boost/circular_buffer.hpp:50:27: No member named 'is_const' in namespace 'boost::move_detail'
there are hundred of errors below.
thanks for reading and have a good day!!!
Thank you for your interest.
I'm sorry
But, I don't understand your request.
circular_buffer.hpp is 3rt_party library from boost.org.
Any time, you can download it for individual OS.
And I send you a link, that is my test project file link in google drive.
If you download it, you might just run it.
https://drive.google.com/open?id=0B4J46iW2HRnoYmNhcVB2OXhkX1U
my test of xcode porject's location:
of_v0.9.4_osx_release/addons/ofDelayLine/BoostTest/boostTest.xcodeproj
If you got Xcode, just double click it on finder.
I just add circular_buffer.hpp on ofApp.h to use it.
I have two C projects that pull in the same library.
One project compiles and links fine, the other gets an "unresolved external reference" linker error for a symbol referenced inside a function which both projects call from the same static library.
As far as I can tell, all the linker and code generation properities of importance are equal between the two.
Is there a way to use the working project, to figure out where the linker in THAT project finds the symbol? I've been using trial and error, including more and more of the libraries from one project into the other with no success.
I found what I wanted! In the Project Properties, under Linker->Debugging, there is an option named "Generate Map File". This can be done on the command-line with /MAP.
The generated map file gets the same name as the project (by default) with .map as file extension. It is a text file containing, among other things, the library name where each symbol is defined.
Using the map file for my project that builds, I was able to quickly find the definition of the symbol missing from my broken project.
This question has been brought up numerous times, but Visual Studio never ceases to challenge me.
We have an application that should be self-sufficient, i.e. not depend on any 3rd party libraries. This is why we build everything statically using the MT(d) code generation flags.
The app depends on Qt, zlib, OpenSSL and DCMTK. All of these libraries were built as static libs with MT(d). The app also uses some MFC-related code, so we also have to link against it.
MFC is included via
#include <afxwin.h>
I read somewhere that this should be the first include in every file, but I'm not sure if it is true. Anyway, the line is not included in every file, only one file includes it.
Here are the link-related errors:
Error 24 error LNK2005: "void __cdecl operator delete[](void *)" (??_V#YAXPAX#Z) already defined in LIBCMTD.lib(delete2.obj) uafxcwd.lib
Error 22 error LNK2005: "void __cdecl operator delete(void *)" (??3#YAXPAX#Z) already defined in LIBCMTD.lib(dbgdel.obj) uafxcwd.lib
Error 23 error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U#YAPAXI#Z) already defined in libcpmtd.lib(newaop.obj) uafxcwd.lib
Error 21 error LNK2005: "void * __cdecl operator new(unsigned int)" (??2#YAPAXI#Z) already defined in LIBCMTD.lib(new.obj) uafxcwd.lib
Here is the linker output.
I read many threads on many sites as well as this article from MSDN's KB. But they don't help me, as all of them keep saying that MFC libs should be linked before CRT, but I cannot find a way to alter the linking order.
Any help is greatly appreciated.
Edit 1:
Using the trick from this thread actually solves the problem, but I still want to know what's wrong here.
Edit 2:
Using Visual Studio 2008 SP1, on Windows 7 and Qt 4.6.3
The problem is clear: you are compiling CRT and MFC code together.
When you use the MFC libraries, you
must make sure that they are linked
before the CRT library is linked. You
can do this by making sure that every
file in your project includes
Msdev\Mfc\Include\Afx.h first, either
directly (#include ) or
indirectly (#include ). The
Afx.h include file forces the correct
order of the libraries, by using the directive:
#pragma comment (lib,"<libname>")
Microsoft has an article (link now gone, but check here) describing this problem and suggests 2 solutions step-by-step (the following steps are based on Visual C++ 6.0):
Solution One: Force Linker to Link Libraries in Correct Order
On the Project menu, click Settings.
In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
On the Link tab, click to select Input in the Category combo box.
In the Ignore libraries box, insert the library names (for example, Nafxcwd.lib;Libcmtd.lib).
Note: The linker command-line equivalent in /NOD:<library name>.
In the Object/library modules (VS2008: Properties->Configuration Properties->Linker->Input->Additional Dependencies)box, insert the library names. You must make sure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).
Solution Two: Locate and Correct the Problem Module
To view the current library link order, follow these steps:
On the Project menu, click Settings.
In the Settings For view of the Project Settings dialog box, click to select the project configuration that is getting the link errors.
On the Link tab, type /verbose:lib in the Project Options box.
Rebuild your project. The libraries will be listed in the output window during the linking process.
This was clarified to me on the MSDN Forumns:
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/4e331cb3-e566-4ca6-b7d4-118c3bebd31a
I'm trying to use a static library created by me in Visual C++ 2005 (unmanaged C++). I declare one function "int myF(int a);" into a .h file, I implement it in a .cpp file, I compile it - the .lib file is produced.
I create a new project (a separate solution) in VC++ 2005 (also native C++), I add the paths for the include file and the lib file; when I invoke the function myF the linker reports an error: "error LNK2019: unresolved external symbol _myF referenced in function _main". if I create the client project in the same solution as the library project and then add a reference to the library projects, it works, but I'm not going to implement everything like this, but rather to add external libraries to my projects...
What is wrong?
Thank you.
You need to also include the actual .lib file in your 2nd project (not just the path to it).
There should be an option in the linker settings to do this.
It is not sufficient to list the folder in which MyStatic.lib can be found. You have to explicitly tell the linker that Dependant.vcproj is using MyStatic.lib.
In VS2005 you do this by project properties->Linker->Input->Additional Dependencies. You can also sprinkle some preprosessor stuff in the .h file to tell the compiler to tell the linker to use MyStatic.lib.
Edit:
The preprocessor magic goes like this
#pragma comment(lib, "MyStatic.lib")
(EDIT: This was a response to the question of getting the /NODEFAULTLIB error in link phase which has now been deleted... shrug)
You are mixing compiler settings if your are getting the defaultlib error. For example, if you build your library in debug and the build your main in release, you will get this error since they are built to use different versions of the CRTL. This can also happen if you use different settings for linking with the C Runtime as a object library or as a DLL. (See the C/C++ options, the "Code Generation" section, under the "Runtime Library" setting)
In many projects there isn't much you can do if you can't correct the settings of the library (for example, 3rd party libraries). In those cases you have to use the /NODEFAULTLIB switch which is a linker option in the "Input" section called "Ignore Specific Library".
But since you are in control of both the main and the library, build a debug and a release version of your LIB file or make sure your "C/C++;Code Generation;Runtime Library" settings match in both projects.
Try setting additional dependencies in the linker input for a project properties.