-
Notifications
You must be signed in to change notification settings - Fork 31
multiple definition of `websockets2_generic::WebsocketsServer::~WebsocketsServer()' in websocket2_generic library #3
Comments
Thanks for using the library. The problems you experienced happened because the complicated feature of the libraries. You can use either solutions as follows: 1. Better implementationSAMD-Ethernet-Client.ino SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient_Impl.h
2. Another implementationSAMD-Ethernet-Client.ino SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient.cpp
If you are OK with any implementation, please post the result for other people to follow. |
This is the terminal output when running the same example on SAMD21 SeeedStudio XIAO Mo
|
Thank you for offering nice library. I'm using folder named SAMD-Ethernet-Client SAMD-Ethernet-Client.ino I want to use library in EthernetWebSocketsClient.h not SAMD-Ethernet-Client.ino file. Thus, "#include <WebSockets2_Generic.h>" should in EthernetWebSocketsClient.h Putting "#include <WebSockets2_Generic.h>" into .ino file is successful. Also, I already run the examlpe code with my board. In addition, I succed to connect websocket server. However, I want to make saperate file EthernetWebSocketsClient.h which using websocket library for code management. For more easy explanation. Here is an example. EthernetWebSocketsClient.h
Thank you for your reply. |
You can use this solution as follows: SAMD-Ethernet-Client.ino SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient_Impl.h
|
It works Thaks a lot. But what is the reason it makes error with ".cpp" file? |
That's left for you to research and investigate. Thanks for confirming the solution. |
Thank you for your reply |
HI.
I’m using ‘adafruit feather m0’ board with w5500 and I succeed to run example code “SAMD-Ethernet-Client”. Also, I communicate server using websocket2_generic library. Then I want to separate code into two files.
While I was trying to make separate WebSocket header file using websockets2_generic library, I face weird error. I try to figure out it, but It was very complicated with my codes. Thus, I remove all of my code except necessary things such as “#define” and “#include”.
I have four files which is
SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient.cpp
defines.h
As the file name, I use the example code. defines.h is almost same with example code. I just remove unnecessary global values.
Other files are same below.
SAMD-Ethernet-Client.ino
EthernetWebSocketsClient.h
EthernetWebSocketsClient.cpp
As I mentioned before, I remove all the code. Those are the full code. When compiling, it shows error like below
c:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO
1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in function1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in functionstd::function<void (websockets2_generic::WebsocketsClient&, websockets2_generic::WebsocketsMessage)>::operator bool() const': C:\Arduino\libraries\WebSockets2_Generic-master\src/Tiny_Websockets_Generic/internals/wscrypto/sha1.hpp:73: multiple definition of
websockets2_generic::WebsocketsServer::WebsocketsServer()'; C:\Users\CHANYO1\AppData\Local\Temp\arduino_build_4918\sketch\EthernetWebSocketsClient.cpp.o:C:\Arduino\libraries\WebSockets2_Generic-master\src/WebSockets2_Generic_Server.hpp:182: first defined herec:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO
std::function<void (websockets2_generic::WebsocketsClient&, websockets2_generic::WebsocketsMessage)>::operator bool() const': C:\Arduino\libraries\WebSockets2_Generic-master\src/Tiny_Websockets_Generic/internals/wscrypto/sha1.hpp:73: multiple definition of
websockets2_generic::WebsocketsServer::WebsocketsServer()'; C:\Users\CHANYO1\AppData\Local\Temp\arduino_build_4918\sketch\EthernetWebSocketsClient.cpp.o:C:\Arduino\libraries\WebSockets2_Generic-master\src/WebSockets2_Generic_Server.hpp:182: first defined herec:/users/chanyoung/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\CHANYO~1\AppData\Local\Temp\arduino_build_4918\sketch\SAMD-Ethernet-Client.ino.cpp.o: in function `websockets2_generic::WebsocketsServer::~WebsocketsServer()':
It shows multiple definition.
I change codes in EthernetWebSocketsClient.h, SAMD-Ethernet-Client.ino.
SAMD-Ethernet-Client.ino
SAMD-Ethernet-Client.ino
I just change the location of
Then, I succeed to compile and linking.
I want to implement websocket functions in EthernetWebSocketsClient.cpp file. Thus, EthernetWebSocketsClient.h include websocket2_generic library.
How can I include websocket2_generic library in EthernetWebSocketsClient.h file.
The text was updated successfully, but these errors were encountered: