-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move the CPPAD_LIB_EXPORT decorator from function definition to function declaration #61
Move the CPPAD_LIB_EXPORT decorator from function definition to function declaration #61
Conversation
As I understand the code in define.hpp, if one is compiling on windows they should add
to the cmake command line. Is this what you are doing ? Also, I think that the CPPAD_LIB_EXPORT marco is also needed for the functions in the following include files:
Does this seem correct to you ? |
No, the |
In that case, it does not need to be discussed in the CppAD the cmake documentation |
Exactly. |
I must have done something wrong. I am testing the current version using the instructions under Visual Studio on and am getting the following errros:
|
CppAD/include/cppad/local/define.hpp Line 60 in 79e1cfd
CPPAD_LIB_EXPORT should be defined as empty and not as __declspec(dllimport) .This is the reason why https://cmake.org/cmake/help/latest/module/GenerateExportHeader.html is tipically used to generate those headers, to generate different code depending on the type of library that is compiled (if shared or static). However, if you only support consuming the library using CMake on Windows, a relatively easy fix is to modify the snippet of code as:
and then in CMake add:
|
Sorry for not noticing this before. |
An alternative to support shared libraries on Windows without manually managing the visibility with |
Thanks !!
In fact, my cmake output has |
Yes, for how the CMake is now, it is only possible to compile static libraries on Windows. |
I changed cppad_lib/CMakeLists.txt to build shared libraries on windows and fixed a few more problems that came up during Now I am stuck on the following error during the
You can build just the offending object with the command You can also see the failure here: |
I think I figured it out. One needs to add the directory where the library was built to the system path. |
A common strategy for that is to set:
so that all the .exe and .dll during build go in |
Given the results of my testing, it seems to me that a static variable in a C++ template function can different values in the DLL than in the rest of the code for a program. Is this true ? |
I am not sure what you mean by "can different values" ? |
Suppose I have a template function:
On unix, there would be one counter for calls to Actually, I think what is causing the CppAD tests to fail is that there are two versions of the static function
in the file More generallly, CppAD assumes there is one version of each function (that has a static variable). Care is take to make sure that these variables are different for different threads or they are only changed in single thread mode. |
I have reverted back to building a static version of the library when using windows; see the heading Visual Studio on If someone wants to try and make the shared version work; they will need to re-enable the definition of CPPAD_LIB_EXPORT in define.hpp and CMakeLists.tst; see the changes to CMakeLists.txt and define.hpp on. I started a discussion about this topic; see |
Does anyone find the way of How to build a DLL file for CppAD on Windows? I saw you guys started a discussion for this but still found no ways of that, please tell me how if anyone knows this, which would be of much help for me and I would appreciated it so much!!!!!!!!!!!!!!! |
This PR fixes #60
cc @traversaro @S-Dafarra