webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.37k stars 146 forks source link

examples build& run ok, but failed building when integrate into my project. #309

Closed laozhang99 closed 5 months ago

laozhang99 commented 5 months ago

I am using mingw64 on win10, my project build result:

g++ ./build/msys_nt-10.0-19043-debug/.o -lz -lwebui-2-static -L/D/projs/network/webui-main//dist/ -luv -L/D/projs/network/libuv-v1.47.0//src/build/mingw64_nt-10.0-19043-release/ -lWs2_32 -lUserenv -lIphlpapi -lDbghelp -lOle32 -mconsole C:/tools/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./build/msys_nt-10.0-19043-debug/webserver_webui.o: in function startWebServer()': D:/projs/coding-git/mctrl/client-uv/webserver_webui.cpp:6: undefined reference towebui_new_window()'
C:/tools/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/projs/coding-git/mctrl/client-uv/webserver_webui.cpp:7: undefined reference to `webui_show(unsigned long long, char const
)' C:/tools/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./build/msys_nt-10.0-19043-debug/webserver_webui.o: in function stopWebServer()': D:/projs/coding-git/mctrl/client-uv/webserver_webui.cpp:12: undefined reference towebui_wait()' C:/tools/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/projs/coding-git/mctrl/client-uv/webserver_webui.cpp:13: undefined reference to `webui_clean()' collect2.exe: error: ld returned 1 exit status

but the libwebui-2-static.a have these functions: sh-5.2$ nm libwebui-2-static.a | grep webui_wait 0000000000002293 T webui_wait

I dont why, the same command build webui's examples is ok. please help, thanks

AlbertShown commented 5 months ago

Try to change the order of linking.

laozhang99 commented 5 months ago

I found the reason. I used g++ instead of gcc, the webui.h lack "extern C" declare, added it and recompiled the whole lib , everything runs well

jinzhongjia commented 5 months ago

ok, so this issue could be closed ?

AlbertShown commented 5 months ago

Glad that's is working for you 👍 Should we add extern C ?

jinzhongjia commented 5 months ago

Glad that's is working for you 👍 Should we add extern C ?

.... g++ is for cpp, gcc is for c when develop cpp, should use .hpp header file, it is for cpp .h is for c