Skip to content
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

drogon with BUILD_EXAMPLES=ON does not link on versions 1.9.7 & 1.9.8 (possibly also 1.9.6) #2208

Closed
eniv opened this issue Nov 10, 2024 · 11 comments

Comments

@eniv
Copy link
Contributor

eniv commented Nov 10, 2024

Looks like an issue with the async_stream example:

[ 79%] Linking CXX executable async_stream
/usr/bin/ld: CMakeFiles/async_stream.dir/async_stream/main.cc.o: in function `void drogon::internal::HttpBinder<main::{lambda(std::shared_ptr<drogon::HttpRequest> const&, std::shared_ptr<drogon::RequestStream>&&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&)#2}>::run<, 0ul, true, false>(std::deque<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, std::shared_ptr<drogon::HttpRequest> const&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&) [clone .constprop.0] [clone .isra.0]':
main.cc:(.text+0x1086): undefined reference to `drogon::RequestStreamReader::newReader(std::function<void (char const*, unsigned long)>, std::function<void (std::__exception_ptr::exception_ptr)>)'
/usr/bin/ld: CMakeFiles/async_stream.dir/async_stream/RequestStreamExampleCtrl.cc.o: in function `RequestStreamExampleCtrl::stream_upload(std::shared_ptr<drogon::HttpRequest> const&, std::shared_ptr<drogon::RequestStream>&&, std::function<void (std::shared_ptr<drogon::HttpResponse> const&)>&&) const':
RequestStreamExampleCtrl.cc:(.text._ZNK24RequestStreamExampleCtrl13stream_uploadERKSt10shared_ptrIN6drogon11HttpRequestEEOS0_INS1_13RequestStreamEEOSt8functionIFvRKS0_INS1_12HttpResponseEEEE[_ZNK24RequestStreamExampleCtrl13stream_uploadERKSt10shared_ptrIN6drogon11HttpRequestEEOS0_INS1_13RequestStreamEEOSt8functionIFvRKS0_INS1_12HttpResponseEEEE]+0x260): undefined reference to `drogon::RequestStreamReader::newMultipartReader(std::shared_ptr<drogon::HttpRequest> const&, std::function<void (drogon::MultipartHeader)>, std::function<void (char const*, unsigned long)>, std::function<void (std::__exception_ptr::exception_ptr)>)'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/CMakeFiles/async_stream.dir/build.make:119: examples/async_stream] Error 1
make[1]: *** [CMakeFiles/Makefile2:574: examples/CMakeFiles/async_stream.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Am I missing something?

@fantasy-peak
Copy link
Contributor

Are there other versions of drogon on your system?

@eniv
Copy link
Contributor Author

eniv commented Nov 11, 2024

No, I just checked. Or to be more accurate, not installed. There is a very old one in a local trash folder.
I'm pretty sure the examples are linked against the version of libdrogon being built.

@fantasy-peak
Copy link
Contributor

Maybe you could empty the build directory and rebuild

@eniv
Copy link
Contributor Author

eniv commented Nov 11, 2024

Thanks for the suggestion. I've already tried that.
In order to prove to myself that I'm linking against the correct version of libdrogon, I checked the dependencies of a different example which did not fail linking. As you can see in the screenshot below, it links against libdrogon1.9.8:
image

Also, I should have noted that earlier. I'm using g++12.3

@eniv
Copy link
Contributor Author

eniv commented Nov 11, 2024

Looks like DROGON_EXPORT is missing in RequestStream.h for the RequestStreamReader class.
Once I add it, the linker is satisfied

@fantasy-peak
Copy link
Contributor

Thanks for the suggestion. I've already tried that. In order to prove to myself that I'm linking against the correct version of libdrogon, I checked the dependencies of a different example which did not fail linking. As you can see in the screenshot below, it links against libdrogon1.9.8: image

Also, I should have noted that earlier. I'm using g++12.3

It's very strange,I can compile by using gcc13.1 14.2.

@eniv
Copy link
Contributor Author

eniv commented Nov 11, 2024

Something must have changed after 12.3 with the visibility attribute.

@hwc0919
Copy link
Member

hwc0919 commented Nov 12, 2024

It's strange. I'm using gcc 11.1 and it works fine.

@fantasy-peak
Copy link
Contributor

It's strange. I'm using gcc 11.1 and it works fine.

maybe only gcc12.not work

@hwc0919
Copy link
Member

hwc0919 commented Nov 12, 2024

Maybe it's because the shared lib. I'm using static lib. But shared lib linkage is also tested in ci.

an-tao pushed a commit that referenced this issue Nov 26, 2024
…est with gcc12.3 when building with shared libs (#2208) (#2213)

* Respect find_package QUIET

* Add policy_max to cmake_minimum_required
Avoid deprecation warning introduced by cmake 3.31

* Add missing DROGON_EXPORT
@eniv
Copy link
Contributor Author

eniv commented Nov 26, 2024

Fixed in #2213

@eniv eniv closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants