A related issue, possibly the cause of the problem I am experiencing, seems to be that neither
itpp_EXPORTS nor itpp_debug_EXPORTS
seems to be defined when they are used in itexports.h but it seems one of them need to be set in order to define
ITPP_EXPORT __declspec(dllexport)
in itexports.h such as not to get many compilation errors of this type:
error C2491: 'itpp::Normal_RNG::ktab': definition of dllimport static data member not allowed
Now, according to the code,
itpp_EXPORTS and itpp_debug_EXPORTS
are supposed to be automatically defined by cmake, except where is this happening and/or how can one chaeck that this is the case?
Also, since itpp_EXPORTS nor itpp_debug_EXPORTS is defined, I am getting a compilation error in several 'itpp\protocol' files that won't compile due to the header file code being bypassed for this case, which seems to be intended as "PROTOCOL definitions are not available for MSVC shared builds", except this bypasing leads to a compilaion error.
Would be great if someone could shed some light on the build process of IT++ with MS Visual Studio 2022.
Last edit: Erik Lindskog 2024-03-31
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How about that. By changing ITPP_SHARED_LIB to 'off' in CMake I was able to get the code to build. (I guess this builds a static library?)
I do however get a lot of warnings of this type:
warning C4273: 'tgamma': inconsistent dll linkage
Not sure if one need to pay attention to these warning messages.
Also, I have not yet tested that this library works.
Further, the file with the library, itpp_debug.lib (64 bit debug without usage of BLAS and LAPACK and such) becomes VERY big, 532 MB. That seems a bit odd.
When I try to build it for release mode, then it fails with a couple of these errors:
error C2169: 'log2': intrinsic function, cannot be defined.
I am under the impression that IT++ has code in it to handle the log2 conflicts but maybe it is not working in this case for some reason.
Last edit: Erik Lindskog 2024-04-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IT++ has not been updated for quite some time, but should still be compatible with VS 2022.
For the best results, you should follow this page: https://itpp.sourceforge.net/4.3.1/installation.html
and use the default options when generating from cmake the VS solution, i.e.
ITPP_SHARED_LIB=ON
The above option generates the shared library (DLL): itpp.dll (and the associated .lib file) into
${CMAKE_BUILD_DIR}/itpp/Debug folder (assuming you generate the debug build).
The compilation warnings can be ignored for now (but they will be solved by a separate pull request).
This header file, itexports.h, is automatically generated by cmake and contains the defines required to use the DLL in your project.
regards
Bogdan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the information. I will study it further.
For whatever reason I am at the moment running into trouble when I set ITT_SHARED_LIB to 'on' (i.e. checking it in the Windows CMake GUI), so I am setting it to 'off' (i.e. unchecking it in the Windows CMake GUI).
I was able to this way build, presumably, a static library, in 64 bit debug mode, even though it became suspiciously large, 523 MB .
When I switch to build it in release mode I had add the line:
#define HAVE_LOG2 1
in config_msvc.h in (after CMake generated it) in order to not get the error:
error C2169: 'log2': intrinsic function, cannot be defined .
Even the release itpp_debug libary (without FFTW, BLAS, and LAPACK) is a bit big, 324 MB, but maybe that is what it should be.
I guess I will try here and see if these libraries are working before I proceed more. Would be nice if I could get the building of the shared library to work.
Note that I am, for better or worse, are building these in 64 bit. Not sure if that is neccessary, or even possible.
Best Regards,
Erik
Last edit: Erik Lindskog 2024-04-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, if one would like to use IT++ in a Matlab mex file from a 64 bit Matlab:
"MathWorks Support Team on 27 Jun 2009
0
Link
The ability to compile 64-bit MEX-files that access functions in 32-bit DLL's is not available in MATLAB. 64-bit applications such as 64-bit MATLAB can only use 64-bit shared libraries. In general, you cannot mix 32-bit and 64-bit code in a single application. If you have a 64-bit application, everything related to that application, including the DLLs, must be compiled as 64-bit."
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the same directory I also placed a copy of the 'itpp' directory containing the heared files, and your compiled 64 bit IT++ library which to my understanding you need when you use a 'modern' 64 bit Matlab version.
This example performs QPSK modulation in a mex file to be called from Matlab.
Invalid MEX-file '..\itpp_qpsk_modulation_mex_function.mexw64': The specified module could not be found.
This error message is a little odd though as that file indeed exists.
Maybe something with the supposed dynamic linking is not working? I think in this case we may be building a shared library. Not sure if one need to do something different when mexing it in this case.
It would be nice if one could get this command line version of the building to work, and of course to get it to build a working shared library.
Course, in any case the above (see previous comments) way of building a static library with CMake followed by Visual Studio (2022) in its GUI interface seems to work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Anybody else getting build errors of the type:
itpp-4.3.1\itpp\protocol\packet_channel.cpp(38,1): error C2653: 'Packet_Channel': is not a class or namespace name
when trying to build the IT++ library (after CMake configuration) with Visual studio 2022?
Seems if does not like the code:
namespace itpp
{
Packet_Channel::Packet_Channel()
{
parameters_ok = false;
keep_running = false;
}
etc.
in, for example, itpp/protocol/packet_channel.cpp.
Best Regards,
Erik
A related issue, possibly the cause of the problem I am experiencing, seems to be that neither
itpp_EXPORTS nor itpp_debug_EXPORTS
seems to be defined when they are used in itexports.h but it seems one of them need to be set in order to define
ITPP_EXPORT __declspec(dllexport)
in itexports.h such as not to get many compilation errors of this type:
error C2491: 'itpp::Normal_RNG::ktab': definition of dllimport static data member not allowed
Now, according to the code,
itpp_EXPORTS and itpp_debug_EXPORTS
are supposed to be automatically defined by cmake, except where is this happening and/or how can one chaeck that this is the case?
Also, since itpp_EXPORTS nor itpp_debug_EXPORTS is defined, I am getting a compilation error in several 'itpp\protocol' files that won't compile due to the header file code being bypassed for this case, which seems to be intended as "PROTOCOL definitions are not available for MSVC shared builds", except this bypasing leads to a compilaion error.
Would be great if someone could shed some light on the build process of IT++ with MS Visual Studio 2022.
Last edit: Erik Lindskog 2024-03-31
How about that. By changing ITPP_SHARED_LIB to 'off' in CMake I was able to get the code to build. (I guess this builds a static library?)
I do however get a lot of warnings of this type:
warning C4273: 'tgamma': inconsistent dll linkage
Not sure if one need to pay attention to these warning messages.
Also, I have not yet tested that this library works.
Further, the file with the library, itpp_debug.lib (64 bit debug without usage of BLAS and LAPACK and such) becomes VERY big, 532 MB. That seems a bit odd.
When I try to build it for release mode, then it fails with a couple of these errors:
error C2169: 'log2': intrinsic function, cannot be defined.
I am under the impression that IT++ has code in it to handle the log2 conflicts but maybe it is not working in this case for some reason.
Last edit: Erik Lindskog 2024-04-01
Hi Erik
IT++ has not been updated for quite some time, but should still be compatible with VS 2022.
For the best results, you should follow this page: https://itpp.sourceforge.net/4.3.1/installation.html
and use the default options when generating from cmake the VS solution, i.e.
ITPP_SHARED_LIB=ON
The above option generates the shared library (DLL): itpp.dll (and the associated .lib file) into
${CMAKE_BUILD_DIR}/itpp/Debug folder (assuming you generate the debug build).
The compilation warnings can be ignored for now (but they will be solved by a separate pull request).
This header file, itexports.h, is automatically generated by cmake and contains the defines required to use the DLL in your project.
regards
Bogdan
I have created these 2 bug reports:
https://sourceforge.net/p/itpp/bugs/263/
https://sourceforge.net/p/itpp/bugs/264/
Feel free contribute on any of these and/or add more bugs/feature requests if needed.
Last edit: Bogdan Cristea 2024-04-01
Bogdan,
Thanks for the information. I will study it further.
For whatever reason I am at the moment running into trouble when I set ITT_SHARED_LIB to 'on' (i.e. checking it in the Windows CMake GUI), so I am setting it to 'off' (i.e. unchecking it in the Windows CMake GUI).
I was able to this way build, presumably, a static library, in 64 bit debug mode, even though it became suspiciously large, 523 MB .
When I switch to build it in release mode I had add the line:
#define HAVE_LOG2 1
in config_msvc.h in (after CMake generated it) in order to not get the error:
error C2169: 'log2': intrinsic function, cannot be defined .
Even the release itpp_debug libary (without FFTW, BLAS, and LAPACK) is a bit big, 324 MB, but maybe that is what it should be.
I guess I will try here and see if these libraries are working before I proceed more. Would be nice if I could get the building of the shared library to work.
Note that I am, for better or worse, are building these in 64 bit. Not sure if that is neccessary, or even possible.
Best Regards,
Erik
Last edit: Erik Lindskog 2024-04-02
FYI. Why would one need to compile in 64 bits?
Well, if one would like to use IT++ in a Matlab mex file from a 64 bit Matlab:
"MathWorks Support Team on 27 Jun 2009
0
Link
The ability to compile 64-bit MEX-files that access functions in 32-bit DLL's is not available in MATLAB. 64-bit applications such as 64-bit MATLAB can only use 64-bit shared libraries. In general, you cannot mix 32-bit and 64-bit code in a single application. If you have a 64-bit application, everything related to that application, including the DLLs, must be compiled as 64-bit."
I have now tested the (static) 64bit It++ library I was able to build according to my posts above.
I tested the Matlab mex example at the bottom of the page https://itpp.sourceforge.net/4.3.1/group__mexfiles.html that I put in a C++ file named itpp_qpsk_modulation_mex_function.cpp.
In the same directory I also placed a copy of the 'itpp' directory containing the heared files, and your compiled 64 bit IT++ library which to my understanding you need when you use a 'modern' 64 bit Matlab version.
This example performs QPSK modulation in a mex file to be called from Matlab.
My mex build command (in Matlab 2024a):
mex -v itpp_qpsk_modulation_mex_function.cpp -litpp -I"." -output itpp_qpsk_modulation_mex_function
My matlab test call:
input_bits = [ 0 0 0 1 1 0 1 1]; output_symbols = itpp_qpsk_modulation_mex_function(input_bits)
which generstes the output:
output_symbols =
1.0000 + 0.0000i 0.0000 + 1.0000i 0.0000 - 1.0000i -1.0000 + 0.0000i
So, so far this seems to work.
Last edit: Erik Lindskog 2024-04-06
Now, a friend of mine showed me how to build the IT++ library with Cmake from the comand line in Windows.
Create a 'build' directory in the directory for your downloaded version 4.3.1 if IT++, the current latest version.
Open the Visual Studio Developers Command line tool (or the Visual Studio Command line tool) from within Visual Studio (2022).
Go to your creaated build directory.
Make the commands:
cmake ..
cmake --build .
For me this creates an IT++ library in build\itpp\Debug\itpp.lib
However, at least for me, this library is quite small, only around 2 MB, so maybe there is something not right with it.
The mexing a la:
mex -v itpp_qpsk_modulation_mex_function.cpp -litpp -I"." -output itpp_qpsk_modulation_mex_function
works with this library but the Matlab call:
input_bits = [ 0 0 0 1 1 0 1 1]; output_symbols = itpp_qpsk_modulation_mex_function(input_bits)
fails with the error:
Invalid MEX-file '..\itpp_qpsk_modulation_mex_function.mexw64': The specified module could not be found.
This error message is a little odd though as that file indeed exists.
Maybe something with the supposed dynamic linking is not working? I think in this case we may be building a shared library. Not sure if one need to do something different when mexing it in this case.
It would be nice if one could get this command line version of the building to work, and of course to get it to build a working shared library.
Course, in any case the above (see previous comments) way of building a static library with CMake followed by Visual Studio (2022) in its GUI interface seems to work.