Closed Dediggefedde closed 1 month ago
Hi, I'm not familiar with BCC32C. I would expect a project using BCC32C to be able to use the library, though it wouldn't be able to build the library at the moment as you noticed (one back-end for the library uses inline-assembly which is different for every compiler). I'm not familiar with OMF, does BCC32C not support normal static libraries / dlls?
-DCPPTRACE_STATIC_DEFINE
is a compiler flag to use in your project if you link against a static version of the library.
It would be helpful if you could send an example of a full linker error, e.g. if the symbol contains __imp__
then it's likely a problem with missing -DCPPTRACE_STATIC_DEFINE
.
I am realizing the local user installation notes are in need of updating and are tailored for linux at the moment. After making a build directory on windows and running cmake
, try running msbuild cpptrace.sln
(you may need to open a developer command prompt / powershell for msbuild
to be in the PATH). Then msbuild INSTALL.vcxproj
should install the built library to the install path you specified.
Hi! Thank your for the quick reply!
I used cmake.exe .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/Downloads/stacktrace
, but the output contained Manually-specified variables were not used by the project:CMAKE_BUILD_TYPE
Then I called MSBuild.exe .\cpptrace.sln
, but the custom build path was ignored.
Instead the files were created in cpptrace/build
and only a x64 (debug) lib-file was generated.
I opened the sln file in visual studio and switched it to x32.
I'm sorry that information was missing in my report. The full text of the error is
[ilink32 Error] Error: Unresolved external 'cpptrace::generate_trace(unsigned int)' referenced from D:\GITS\Software\WIN32\DEBUG\Software_01.OBJ [ilink32 Error] Error: Unresolved external 'cpptrace::stacktrace::to_string(bool) const' referenced from D:\GITS\Software\WIN32\DEBUG\Software_01.OBJ [ilink32 Error] Error: Unable to perform link Failed
OMF was the original format, invented by Intel and is still used at some places. However, C++ Builder also made an announcement last year, that the next bigger version would support COFF natively. Until then it provides a COFF2OMF.exe converter. But since it will then also support C++23, we might actually switch to std::stacktrace anyway.
However, when I checked the content of the converted OMF lib-file, it is almost empty. Other convertes COFF-to-OMF converters also complained that "Unsupported relocation type (0)" and "Different alignments specified for same segment, _rdata. Using highest alignment". In past projects, conversion seem to work fine, but I also heard it requires specific naming conventions.
Since it does not look like I can link the lib file statically, can I generate a dll file and link it dynamically?
Hi, you can try adding -DBUILD_SHARED_LIBS=On
to build a DLL
I'm going to go ahead and close this, if you have any further questions please don't hesitate to ask!
I would like to use the library in a project made in Embarcadero's C++ Builder (Community Edition), which uses the clang-enhanced BCC32C compiler using C++17. The project is a x32 applications for windows and I would like to link the library statically. However, I have trouble generating or linking the library file.
When I tried to install the library in a Windows machine according to the "Local User Installation" section, the
make
command said "nothing to be done". So, I opened the .sln file, which cmake produced, in Visual Studio 2022 and build the libraries from there. I also added -DCPPTRACE_STATIC_DEFINE to the linker as an option, but it is reported as unkown option. Since this generates a COFF-based lib file, I used Embarcadero's COFF2OMF.exe converter to get a OMF. Compiling the library directly in C++ Builder triggered the "unsupported compiler warning".In the C++ Builder project, I added the converted .lib file and included the cpptrace.hpp file. The linker gets the additional options
-lcpptrace -ldbghelp -DCPPTRACE_STATIC_DEFINE
However, at the end, the linker complains that it can not resolve the cpptrace functions, like
cpptrace::generate_trace(unsigned int)
.Did I set this up wrong? I didn't do this very often and was unsure where to set the flags. Or are BCC32C projects simply not supported?