WhyCan Forum

人过留名,雁过留声,感谢各位朋友不离不弃地支持。 QQ: 516333132, 微信: whycan_cn (挖坑网/填坑网) admin@whycan.cn

您尚未登录。

#1 2019-11-02 17:39:05

xgui
会员
注册时间: 2019-09-07
累计积分: 172

Windows 编译 libvncclient 的demo程序出问题了, 使用的是 SDL2 库

17:37:26: 为项目example_viewer执行步骤 ...
17:37:26: 配置没有改变, 跳过 qmake 步骤。
17:37:26: 正在启动 "D:\Qt\Qt5.12.3\Tools\mingw730_32\bin\mingw32-make.exe" -j2

D:/Qt/Qt5.12.3/Tools/mingw730_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'F:/libvncserver/build-example_viewer-Desktop_Qt_5_12_3_MinGW_32_bit-Debug'
gcc -c -fno-keep-inline-dllexport -g -Wall -W -Wextra -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../example -I. -I../../libvncserver -I../common -I../libvncserver -I../zlib-1.2.11 -I../sdl/include/SDL2 -ID:/Qt/Qt5.12.3/5.12.3/mingw73_32/include -ID:/Qt/Qt5.12.3/5.12.3/mingw73_32/include/QtGui -ID:/Qt/Qt5.12.3/5.12.3/mingw73_32/include/QtANGLE -ID:/Qt/Qt5.12.3/5.12.3/mingw73_32/include/QtCore -Idebug -ID:/Qt/Qt5.12.3/5.12.3/mingw73_32/mkspecs/win32-g++  -o debug/SDLvncviewer.o ../client_examples/SDLvncviewer.c
../client_examples/SDLvncviewer.c: In function 'kbd_leds':
../client_examples/SDLvncviewer.c:214:33: warning: unused parameter 'cl' [-Wunused-parameter]
 static void kbd_leds(rfbClient* cl, int value, int pad) {
                                 ^~
../client_examples/SDLvncviewer.c:214:52: warning: unused parameter 'pad' [-Wunused-parameter]
 static void kbd_leds(rfbClient* cl, int value, int pad) {
                                                    ^~~
../client_examples/SDLvncviewer.c: In function 'got_selection':
../client_examples/SDLvncviewer.c:421:38: warning: unused parameter 'cl' [-Wunused-parameter]
 static void got_selection(rfbClient *cl, const char *text, int len)
                                      ^~
../client_examples/SDLvncviewer.c:421:64: warning: unused parameter 'len' [-Wunused-parameter]
 static void got_selection(rfbClient *cl, const char *text, int len)
                                                                ^~~
../client_examples/SDLvncviewer.c: In function 'get_credential':
../client_examples/SDLvncviewer.c:429:49: warning: unused parameter 'cl' [-Wunused-parameter]
 static rfbCredential* get_credential(rfbClient* cl, int credentialType){
                                                 ^~
g++ -static -Wl,-subsystem,windows -mthreads -o debug/example_viewer.exe @object_script.example_viewer.Debug  -lws2_32 -L../sdl/lib -lSDL2 -LD:/Qt/Qt5.12.3/5.12.3/mingw73_32/lib D:/Qt/Qt5.12.3/5.12.3/mingw73_32/lib/libQt5Guid.a D:/Qt/Qt5.12.3/5.12.3/mingw73_32/lib/libQt5Cored.a   
d:/Qt/Qt5.12.3/Tools/mingw730_32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/../../../../i686-w64-mingw32/lib/../lib\libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x39): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [Makefile.Debug:137: debug/example_viewer.exe] Error 1
mingw32-make[1]: Leaving directory 'F:/libvncserver/build-example_viewer-Desktop_Qt_5_12_3_MinGW_32_bit-Debug'
mingw32-make: *** [Makefile:38: debug] Error 2
17:37:37: 进程"D:\Qt\Qt5.12.3\Tools\mingw730_32\bin\mingw32-make.exe"退出,退出代码 2 。
Error while building/deploying project example_viewer (kit: Desktop Qt 5.12.3 MinGW 32-bit)
When executing step "Make"
17:37:38: Elapsed time: 00:11.

离线

#2 2019-11-02 17:40:05

xgui
会员
注册时间: 2019-09-07
累计积分: 172

Re: Windows 编译 libvncclient 的demo程序出问题了, 使用的是 SDL2 库

2019-11-02_173950.png

离线

#3 2019-11-02 17:40:54

xgui
会员
注册时间: 2019-09-07
累计积分: 172

Re: Windows 编译 libvncclient 的demo程序出问题了, 使用的是 SDL2 库

后来终于找到解决方法了: https://stackoverflow.com/questions/17048072/sdl-2-undefined-reference-to-winmain16-and-several-sdl-functions

#define SDL_MAIN_HANDLED

in your main file, BEFORE the line

#include <SDL2/SDL.h>

离线

#4 2019-11-20 12:00:10

jimmy
Moderator
注册时间: 2017-10-29
累计积分: 274

Re: Windows 编译 libvncclient 的demo程序出问题了, 使用的是 SDL2 库

在 main 函数前执行

#undef main

也可以的

离线

页脚