Open MonicaLiu0311 opened 1 year ago
Thanks for reporting. All of the import / export handling is done through generate_export_header(), which generates _influxdbexport.h and related macros. The docs don't mention any additional settings or defines needed for MSVC.
I don't have a MSVC around to check the generated file, but I assume it should look similar to GCC / Clang. The attached log contains many other errors, could they lead to the linker issues listed above?
could they lead to the linker issues listed above?
Yes, when I using the way influxdb-cxx#installation to build 0.7.1
, LNK2001 and LNK2019 appeared, but the previous 0.6.7
was built successfully.
Doing a quick diff between both version I can't see any reason for the linker issues, the export related settings haven't changed. Only SOVERSION introduced with 0.7.0, which seems to work different on Windows.
Can you bisect the commit introducing the linker issues?
Can you bisect the commit introducing the linker issues?
Sorry I'm late (on vacation), do you mean that you want me to separate error LNK2001 and LNK2019 into two issues? But they are all caused by the same reason.
If I misunderstood something, please correct me.
Sorry I'm late (on vacation), do you mean that you want me to separate error LNK2001 and LNK2019 into two issues?
No, the issue is fine :-)
--> Doing a Git Bisect to determine the commit which may have introduced the linker issues. Let me know if you need some help here.
--> Doing a Git Bisect to determine the commit which may have introduced the linker issues. Let me know if you need some help here.
I found the commit where the error occurred for the first time: https://github.com/offa/influxdb-cxx/commit/4f1f45ed5cf440cea25de2a6afb5be7e00970678
4f1f45ed5cf440cea25de2a6afb5be7e00970678
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[4f1f45ed5cf440cea25de2a6afb5be7e00970678] Replace curl with cpr (#93)
Just to be on the safe side, I also tried the commits before and after it to make sure it was the culprit.
Thanks!
So introducing neither the SOVERSION is the reason, nor are there any import / export related changes. The commit replaces one library with another without touching much code (except HTTP).
I don't understand how this affects, eg. TCP not finding InfluxDBException
symbols – both not modified:
TCP.cxx.obj : error LNK2001: unresolved external symbol "declspec(dllimport) public: cdecl influxdb::InfluxDBException::InfluxDBException(class std::basic_string<char,struct std::char_traits
,class std::allocator > const &)"
I don't understand how this affects
I don't have a clue either🙁
Could the changes to src/CMakeList.txt in the mentioned commit cause the problem? Maybe MSVC doesn't cope with object libraries?
Could the changes to src/CMakeList.txt in the mentioned commit cause the problem?
I'm not sure...but I'd be happy to verify your patch if you have an idea.
Maybe MSVC doesn't cope with object libraries?
In general, when using object libraries as dependencies of other targets, MSVC will automatically include the object files into the final executable or library during the linking phase.
But why does it affect the macro definition in influxdb_export.h
?
But why does it affect the macro definition in influxdb_export.h?
Is there even a difference between the broken commit and the commit before?
I have same errors if trying to build from master
on Windows Server 2019 and MSVC 2022. The reason why I'm trying to build influxdb-cxx
by myself is that the vcpkg package influxdb-cxx
throws an exception on any query or connection by udp/tcp transport. It looks like this is boost related issue.
@MonicaLiu0311 Do you observe the same problem with queries to databases?
The reason why I'm trying to build influxdb-cxx by myself is that the vcpkg package influxdb-cxx throws an exception on any query or connection by udp/tcp transport. It looks like this is boost related issue.
Sounds like it was built without boost.
Sounds like it was built without boost.
I suppose it is built with boost. In other case influxdb-cxx
throws a meaningful exceptions like Query requires Boost
. In my case the program just crashes with abort() has been called
(not exception as mentioned above).
@offa, anyway I can't build the library on Windows. Could you please point me in the right direction.
Thanks for the clarification, it wasn't clear from the comment what type of exception.
I'm no MSVC dev, but following the steps described in the Readme should work there too.
There's a CI build for MSVC; it uses Conan to ship dependencies but maybe you can use it a a reference.
Can you describe the steps you use?
My project is deeply tied with vcpkg. So steps are:
vcpkg install boost
influxdb-cxx
in CLion or Visual Studiobuild all
I tried to set flags -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS_INIT=-D_WIN32_WINNT=0x0A00
but it takes no effect.
After several unsuccessful attempts I have built the lib and my project with vcpkg and conan as well.
The clues are these cmake's args -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS_INIT=-D_WIN32_WINNT=0x0A00
in right place in cmake.
@offa Thanks a lot for the reference to the solution.
Great to hear! :-)
@MonicaLiu0311 is this solved for you?
@MonicaLiu0311 is this solved for you?
Still the same error.
Hi there! I'm a maintainer from Conan Center and currently reviewing the PR to add this library into our repository and facing the same issue.
Upon investigation, the issue is caused by the InfluxDB
library target being composed of three separate object libraries
add_library(InfluxDB
$<TARGET_OBJECTS:InfluxDB-Core>
$<TARGET_OBJECTS:InfluxDB-Internal>
$<TARGET_OBJECTS:InfluxDB-BoostSupport>
)
add_library(InfluxData::InfluxDB ALIAS InfluxDB)
The generate_export_header(InfluxDB)
does indeed generate the header file, which causes CMake to pass the relevant macro to the InfluxDB
target. However, because this library has no sources of its own - the sources for InfluxDB-Core
, InfluxDB-Internal
and InfluxDB-BoostSupport
are being compiled without the relevant macro needed - so nothing gets really exported when building the shared library, resulting in the errors.
So the behaviour of generate_export_header(InfluxDB)
is not affecting the actual translation units where the macro defines are needed.
Simular issues are reported:
however no solution is provided.
My recommendation based on looking at https://github.com/offa/influxdb-cxx/blob/master/src/CMakeLists.txt would be perhaps to have a single target with all the sources, rather than separate object targets - given how few files are involved, and the conditionals can still be kept.
Thanks, this indeed could explain the issue. Previously only non-public components were build as object libraries with all public source files in the main library.
There's a test on 194-remove_internal_target
branch, which builds without the internal library (let me know if you need it for 0.7.x instead). Can someone test it?
Hello, I am the maintainer of vcpkg. In the process of updating to
v0.7.1
, I found the following error. After investigation, I found thatInfluxDB_EXPORTS
was not defined during dynamic linking, which caused it to execute__declspec(dllimport)
.For further confirmation, I abandoned vcpkg, built your library separately, and found the same error. See the attachment for details: error.log
Related PR: https://github.com/microsoft/vcpkg/pull/31145