uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.24k stars 1.75k forks source link

linking with uWebSockets fails #1105

Closed jvo203 closed 3 years ago

jvo203 commented 3 years ago

In the most up-to-date Intel Clear Linux using the very latest uWebSockets/uSockets and gcc --version gcc (Clear Linux OS for Intel Architecture) 10.2.1 20200924 releases/gcc-10.2.0-279-gaa47c98734

/usr/bin/ld: /tmp/ccWYdX6b.o: in function uWS::getDecodedQueryValue(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >)': /home/chris/uWebSockets/src/QueryParser.h:25: multiple definition ofuWS::getDecodedQueryValue(std::basic_string_view<char, std::char_traits >, std::basic_string_view<char, std::char_traits >)'; /tmp/ccqhsQ8b.o:/home/chris/uWebSockets/src/QueryParser.h:25: first defined here collect2: error: ld returned 1 exit status

In my Makefile uWebSockets are included/linked to in the following way:

include: -I$(HOME)/uWebSockets/src -I$(HOME)/uWebSockets/uSockets/src

libs: $(HOME)/uWebSockets/uSockets/*.o

ghost commented 3 years ago

There is no include guard I forgot to add. Try if you add one yourself. I still have a few fixes to add.

jvo203 commented 3 years ago

Hello, just as you say there seem to be a few fixes remaining to be added. Git pull on uWebSockets still produces the error, albeit with a different line number (due to the extra lines added by you to QueryParser.h):

/usr/bin/ld: /tmp/cclDUYKe.o: in function uWS::getDecodedQueryValue(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >)': /home/chris/uWebSockets/src/QueryParser.h:28: multiple definition ofuWS::getDecodedQueryValue(std::basic_string_view<char, std::char_traits >, std::basic_string_view<char, std::char_traits >)'; /tmp/cczXxiki.o:/home/chris/uWebSockets/src/QueryParser.h:28: first defined here collect2: error: ld returned 1 exit status

ghost commented 3 years ago

Oh you're right. That still needs to be marked inline or put in a struct.

ghost commented 3 years ago

Can you send a PR for this?

jvo203 commented 3 years ago

Will need to learn how to make pull requests. Have never done it before...

jvo203 commented 3 years ago

Hi Alex, no need for a pull request anymore, the fix applied by you works fine.