As the title, I have this error while compiling an hello world demo with gtk in codelite...the exactly error is
C:\WINDOWS\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -e -f Makefile
Building project:[ CodeLiteGTK3 - Debug ]----------
mingw32-make[1]: Entering directory 'C:/Users/Diana/Documents/CodeLiteWorkspace/CodeLiteGTK3'
C:/MinGW/bin/g++.exe -o Debug/CodeLiteGTK3 #"CodeLiteGTK3.txt" -L. -L/mingw64/lib -L/mingw64/lib/../lib -L/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lepoxy -lopengl32 -lgdi32 -lpangocairo-1.0 -lm -lgdi32 -lpangoft2-1.0 -lm -lpangowin32-1.0 -lm -lusp10 -lgdi32 -lpango-1.0 -lm -lfribidi -lthai -ldatrie -latk-1.0 -lcairo-gobject -lcairo -lz -lpixman-1 -lm -pthread -lfontconfig -liconv -lexpat -lfreetype -lbz2 -lharfbuzz -lm -lusp10 -lgdi32 -lrpcrt4 -ldwrite -lgraphite2 -lpng16 -lz -lgdk_pixbuf-2.0 -lm -lgdiplus -lole32 -ljpeg -ljasper -lpng16 -lz -ltiff -lzstd -llzma -ljpeg -lz -lgio-2.0 -pthread -lintl -lshlwapi -ldnsapi -liphlpapi -lws2_32 -pthread -lgmodule-2.0 -lintl -lz -lgobject-2.0 -pthread -lintl -lffi -lintl -lglib-2.0 -lws2_32 -lole32 -lwinmm -lshlwapi -pthread -lpcre
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -ldwrite
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [Debug/CodeLiteGTK3] Error 1
CodeLiteGTK3.mk:78: recipe for target 'Debug/CodeLiteGTK3' failed
mingw32-make[1]: Leaving directory 'C:/Users/Diana/Documents/CodeLiteWorkspace/CodeLiteGTK3'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
====1 errors, 0 warnings====
here the code.
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
gtk_main ();
return 0;
}
can somebody help me please?
Thanks in advance!
as g++ option, add -I/mingw64/include/gtk-3.0/
in Settings -> Build setting -> Compilers
click Apply Ok ..I haven't tried for setting clang++ as compiler though
BTW, edit the code with print Hello world at the first place said
Related
I am currently trying to compile a static C++ application on Linux for Windows. I am using the x86_64-w64-mingw32.static-g++ compiler and used mxe to install the static 64bit versions of the libraries sdl2, sdl2_image, sdl2_ttf and boost. I keep running into these errors, and I think it has something to do with the circular dependency between freetype and harfbuzz:
/home/user/.mxe/usr/bin/x86_64-w64-mingw32.static-ld: /home/user/.mxe/usr/lib/gcc/x86_64-w64-mingw32.static/11.2.0/../../../../x86_64-w64-mingw32.static/lib/../lib/libharfbuzz.a(libharfbuzz_la-hb-ft.o):hb-ft.cc:(.text+0x11fd): undefined reference to `FT_Get_MM_Var'
/home/user/.mxe/usr/bin/x86_64-w64-mingw32.static-ld: /home/user/.mxe/usr/lib/gcc/x86_64-w64-mingw32.static/11.2.0/../../../../x86_64-w64-mingw32.static/lib/../lib/libharfbuzz.a(libharfbuzz_la-hb-ft.o):hb-ft.cc:(.text+0x126b): undefined reference to `FT_Get_Var_Blend_Coordinates'
/home/user/.mxe/usr/bin/x86_64-w64-mingw32.static-ld: /home/user/.mxe/usr/lib/gcc/x86_64-w64-mingw32.static/11.2.0/../../../../x86_64-w64-mingw32.static/lib/../lib/libharfbuzz.a(libharfbuzz_la-hb-ft.o):hb-ft.cc:(.text+0x1366): undefined reference to `FT_Done_MM_Var'
/home/user/.mxe/usr/bin/x86_64-w64-mingw32.static-ld: /home/user/.mxe/usr/lib/gcc/x86_64-w64-mingw32.static/11.2.0/../../../../x86_64-w64-mingw32.static/lib/../lib/libharfbuzz.a(libharfbuzz_la-hb-ft.o):hb-ft.cc:(.text+0x1676): undefined reference to `FT_Set_Var_Blend_Coordinates'
This is the part of my Makefile in which I add the libraries:
WIN_STATIC_LIB = -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lfreetype -lfontconfig -lcairo -lharfbuzz -lbz2 -lstdc++ -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -lwebp -lpng -lz -ljpeg -lSDL2_test -lsamplerate
I compiled a fltk application on linux with Code::blocks (file: test.cpp) without problems and was able to run the test.cpp file from within Code::blocks and from the linux command line.
Now I want to compile the test.cpp file or the whole project (prj.cbp) to a Windows 64 bit executable.
I installed mingw and it works fine because I can convert normal (NOT fltk) .cpp files to .exe files and run them on Windows.
But when I try to compile the test.cpp file with the mingw command (x86_64-w64-mingw32-g++ --static test.cpp -o app.exe) I get this error:
main.cpp:4:10: fatal error: FL/Fl.H: No such file or directory
#include <FL/Fl.H>
^~~~~~~~~
compilation terminated.
How can I fix this and how can I compile .cbp projects to get Windows binaries? Is it possible to do this from in Code::blocks and how do I set the mingw compiler to find the FLTK libraries?
If I try to compile from Code::blocks with the mingw compiler under linux for Windows I get this build log:
`-------------- Build: Debug in newFLTKproject (compiler: MingW64 compiler)---------------
x86_64-linux-gnu-c++ -std=c++14 -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -std=c++14 -g -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -std=c++14 -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT -L/usr/local/lib -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_gl -lGL -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -L/usr/local/lib -lfltk_images -lpng -lz -lfltk_jpeg -lfltk_gl -lGL -lfltk_forms -lfltk -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__ -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/x86_64-w64-mingw32/include -I/usr/local/include/FL -I/usr/local/include -c /home/melt/Documents/C++/FLTK_C++2020/newFLTKproject/main.cpp -o obj/Debug/main.o
x86_64-linux-gnu-g++ -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -L/usr/x86_64-w64-mingw32/lib -L/usr/local/lib -o bin/Debug/newFLTKproject obj/Debug/main.o -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages --use-forms --ldflags --use-gl --ldflags --use-images --ldflags --use-forms --use-gl --use-images --ldflags -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages --use-forms --ldflags --use-gl --ldflags --use-images --ldflags --use-forms --use-gl --use-images --ldflags -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid -lXext -lX11 -lm -lfltkgl -lfltkforms -lfltkimages /usr/local/lib /usr/local/lib /usr/local/lib /usr/x86_64-w64-mingw32/lib
/bin/sh: 1: x86_64-linux-gnu-c++: not found
Process terminated with status 127 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))`
I use this command to compile the file:
g++ rec.cpp -o rec -I /usr/local/include -L /usr/local/lib -lavformat -lavcodec -lavutil -lavdevice -lswscale -lasound -ldl -pthread -lz -lbz2 -lswresample -llzma -lva -lX11
After excute it I got the error:
/usr/bin/ld: /usr/local/lib/libavdevice.a(xcbgrab.o): undefined reference to symbol 'xcb_setup_pixmap_formats_length'//usr/lib/x86_64-linux-gnu/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
How could I cope with this issue?
I found a way to deal with my issue. Since it's definitely a library problem so you can check how many libraries you need before compiling. For example:
pkg-config --libs libavcodec libavformat libswscale libavutil libavdevice
Then it'll tell you:
-L/usr/local/lib -lavdevice -lm -lxcb -lxcb-shm -lxcb -lxcb-shape -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lasound -lavfilter -pthread -lm -lva -ldl -lswscale -lm -lavformat -lm -lbz2 -lz -lavcodec -pthread -lm -llzma -lz -lva -ldl -lswresample -lm -lavutil -pthread -lva -lva-drm -lva -lva-x11 -lX11 -lm -lva -ldl
These libraries are what you need when you compile and then it's done.
You may also need pkg-config --cflags libavcodec libavformat libswscale libavutil libavdevice to add you CFLAGS or CXXFLAGS.
I have tried to compile those files by CodeBlocks which i have downloaded from here:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/frame?h=master
When i try to compile it with Code Blocks i get that error:
main.cpp|8|undefined reference to `ExampleWindow::ExampleWindow()'|
But i compile it like that from terminal it works:
g++ main.cc examplewindow.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
Is there any idea how to make Code Blocks compile two source files ?
-------------- Build: Debug in youtube (compiler: GNU GCC Compiler)---------------
g++ -Wall -fexceptions -g -std=gnu++11 -pthread
-I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/gtk-3.0 -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/atk-1.0 -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/harfbuzz -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -I/usr/include/ -I/usr/lib/x86_64-linux-gnu/ -c /home/bahaa/programming/c++/youtube/main.cpp -o obj/Debug/main.o g++
-o bin/Debug/youtube obj/Debug/main.o -L/usr/lib/mysql -lmysqlclient -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 obj/Debug/main.o: In function main': /home/bahaa/programming/c++/youtube/main.cpp:8: undefined
reference toExampleWindow::ExampleWindow()'
/home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::~ExampleWindow()'
/home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::~ExampleWindow()' collect2: error: ld returned 1 exit
status Process terminated with status 1 (0 minutes, 1 seconds) 3
errors, 0 warnings (0 minutes, 1 seconds)
https://www.youtube.com/watch?v=3v3koVNb7hU&feature=youtu.be
The command you put in your terminal looks completely different from the command codeblocks is executing, so the fact that it does something different is logic.
However in the case of a undefined reference it usually means that you are forgetting an include somewhere. Where is ExampleWindow declared/defined? Is it in included in your main through one of the two includes you are doing?
I dont understand why g++ cannot find getnameinfo in ws2_32, nm shows that it is there. Here is the output:
$ I:/Programs/MinGW/msys/1.0/bin/sh.exe ../libtool --tag=CXX --mode=link g++
-g -O2 -no-undefined -version-info 16:0:0 -o libetpan.la -rpath /i/Programs/M
inGW/lib dummy.lo versioninfo.lo data-types/libdata-types.la low-level/liblow-l
evel.la driver/libdriver.la main/libmain.la engine/libengine.la windows/libarch
.la -L/i/Programs/MinGW/lib -lws2_32 -liconv
libtool: link: rm -fr .libs/libetpan.dll.a
libtool: link: g++ -shared -nostdlib i:/programs/mingw/bin/../lib/gcc/mingw32/4.
7.0/../../../dllcrt2.o i:/programs/mingw/bin/../lib/gcc/mingw32/4.7.0/crtbegin.o
.libs/dummy.o .libs/versioninfo.o -Wl,--whole-archive data-types/.libs/libdat
a-types.a low-level/.libs/liblow-level.a driver/.libs/libdriver.a main/.libs/lib
main.a engine/.libs/libengine.a windows/.libs/libarch.a -Wl,--no-whole-archive
-lws2_32 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -lws2_32 -L/i/Programs/MinGW/lib -l
ws2_32 /mingw/lib/libiconv.dll.a -Li:/programs/mingw/bin/../lib/gcc/mingw32/4.7.
0 -Li:/programs/mingw/bin/../lib/gcc -Li:/programs/mingw/bin/../lib/gcc/mingw32/
4.7.0/../../../../mingw32/lib -Li:/programs/mingw/bin/../lib/gcc/mingw32/4.7.0/.
./../.. -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi3
2 -lshell32 -luser32 -lws2_32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmi
ngwex -lmsvcrt i:/programs/mingw/bin/../lib/gcc/mingw32/4.7.0/crtend.o -O2 -p
thread -o .libs/libetpan-16.dll -Wl,--enable-auto-image-base -Xlinker --out-impl
ib -Xlinker .libs/libetpan.dll.a
Creating library file: .libs/libetpan.dll.a
Warning: resolving _closesocket by linking to _closesocket#4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
low-level/.libs/liblow-level.a(mailsmtp.o): In function `get_hostname':
c:\libetpan-00c7589\src\low-level\smtp/mailsmtp.c:266: undefined reference to `_
getnameinfo'
collect2.exe: error: ld returned 1 exit status
$ nm /i/Programs/MinGW/lib/libws2_32.a | grep getnameinfo
00000000 I __imp__getnameinfo#28
00000000 T _getnameinfo#28
I needed to #define _WIN32_WINNT 0x0501