I'm trying to compile my program for windows, i'm using mingw
i686-w64-mingw32-gcc Pagina_inicial.c -o Pagina_inicial `pkg-config --libs --cflags gtk+-2.0 mysqlclient`
but only the --cflags was find, the --libs does ld return error.
/usr/bin/i686-w64-mingw32-ld: cannot find -lgtk-x11-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lgdk-x11-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lpangocairo-1.0
/usr/bin/i686-w64-mingw32-ld: cannot find -latk-1.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lcairo
/usr/bin/i686-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lgio-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lpangoft2-1.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lpango-1.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lgobject-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lglib-2.0
/usr/bin/i686-w64-mingw32-ld: cannot find -lfontconfig
/usr/bin/i686-w64-mingw32-ld: cannot find -lfreetype
/usr/bin/i686-w64-mingw32-ld: cannot find -lmariadb
/usr/bin/i686-w64-mingw32-ld: cannot find -lz
/usr/bin/i686-w64-mingw32-ld: cannot find -ldl
/usr/bin/i686-w64-mingw32-ld: cannot find -lgnutls
collect2: error: ld returned 1 exit status
I already tryed put the paths manually but problably
im using wrongs paths, someone can helpe me?
Related
A user of xnec2c was trying to build on OSX with clang and got this error:
gcc --pedantic -Wall -std=gnu11 -O2 -g -Wformat -Werror=format-security -fpie -Wno-overlength-strings -DGTK_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGDK_PIXBUF_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-honor-nans -fno-signed-zeros -fno-math-errno -Wl,--export-dynamic -Wl,--as-needed -o xnec2c main.o mathlib.o measurements.o interface.o callbacks.o console.o callback_func.o calculations.o cmnd_edit.o geom_edit.o gnuplot.o draw.o draw_structure.o draw_radiation.o fields.o fork.o geometry.o ground.o xnec2c.o input.o matrix.o utils.o nec2_model.o network.o optimize.o plot_freqdata.o radiation.o rc_config.o shared.o somnec.o xnec2c-resources.o -L/opt/local/lib -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lpthread -lm
ld: unknown option: --export-dynamic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(FYI: GTK Builder needs the export-dynamic linking flag.)
This discussion suggests making the double-dash a single dash:
-AM_LDFLAGS = -Wl,--export-dynamic
+AM_LDFLAGS = -Wl,-export-dynamic
However the user found that, actually, it needs a single dash and an underscore (maybe, still having trouble that could be related, but at least ld stopped barking about the option):
-AM_LDFLAGS = -Wl,--export-dynamic
+AM_LDFLAGS = -Wl,-export_dynamic
Questions:
Does single-dash -Wl,-export-dynamic work in both GCC and Clang?
Whats with the underscore version as -Wl,-export_dynamic?
How compatible is that option with older (and newer) versions of the GCC/Clang stacks?
Other considerations or best practice?
Both GNU ld and LLVM lld take --export-dynamic flag
ld that ships with OS X takes -export_dynamic flag
This has nothing to do with gcc or clang, these only pass the flag along to the linker
I am trying to create a GUI program using gtk3 but I am unable to compile a program that utilize the gtk library! I am running windows 8 and I installed gtk using msys via the following method:
I have dowloaded and installed MSYS2 from msys2 website. I am running the msys2 mingw-w64 64 bits version. I updated everything using pacman -Syu and executed pacman -S mingw-w64-x86_64-gtk3 base-devel mingw-w64-toolchain.
Then I added ;C:\msys64\mingw64\bin to my path via Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables and under the System variables I modified the variable Path and appended ;C:\msys64\mingw64\bin at the end.
I then installed Code::Blocks mingw setup, 64 bit successfully
I created a console application -> c project -> GNU GCC compiler -> create project.
I pasted in the following code into the main.c file, overriding whatever was there as default, with this piece of code
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
printf("Hello world!\n");
return 0;
}
I opened the compiler settings via Settings -> Compiler... -> Other compiler options and appended pkg-config gtk+-3.0 --cflags with '`' on each side (cannot add this here because that is the format for code...
Then I added pkg-config gtk+-3.0 --libs (again with the ยด but in the other direction on each side of the argument) in Linker settings -> Other linker options:
When I try to compile and run the project I get this
Build messages
||=== Build: Debug in gtkdev (compiler: GNU GCC Compiler) ===|
c:\mingw\bin..\lib\gcc\mingw32\8.2.0........\mingw32\bin\ld.exe: obj\Debug\main.o||in function main':|
C:\Users\name\Documents\development\gtkdev\main.c|7|undefined reference togtk_init_abi_check'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
error: ld returned 1 exit status
Build log
mingw32-g++.exe -o bin\Debug\gtkdev.exe obj\Debug\main.o -LC:/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lintl -lglib-2.0 -LC:/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lintl -lglib-2.0
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: obj\Debug\main.o: in function main':
C:/Users/name/Documents/development/gtkdev/main.c:7: undefined reference togtk_init_abi_check'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Output of pkg-config gtk+-3.0 --cflags in msys
-pthread -mms-bitfields -IC:/msys64/mingw64/include/gtk-3.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/pango-1.0 -IC:/msys64/mingw64/include/fribidi -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/atk-1.0 -IC:/msys64/mingw64/include/cairo -IC:/msys64/mingw64/include/pixman-1 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/freetype2 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include/harfbuzz -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/include/libpng16 -IC:/msys64/mingw64/include -IC:/msys64/mingw64/lib/libffi-3.2.1/include -IC:/msys64/mingw64/include/glib-2.0 -IC:/msys64/mingw64/lib/glib-2.0/include -IC:/msys64/mingw64/include
Output of pkg-config gtk+-3.0 --libs in msys
-LC:/msys64/mingw64/lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lintl -lglib-2.0
Using the flags instead of relying on pkg-config does not change anything. Compiling main.c from windows Command Propt using gcc and said flags results in the same error as in Code::Blocks. Moving the order of the options/flags in different ways does not change the error. For example having the libraries last and the cflags directly after gcc or main.c does not change the output, I have seen a "solutions" where there has to be a specific order to compile and link everything correctly, which does not work in the windows Command prompt nor in Code::Blocks apparently. Further more adding the compiler and linker options in Build Options for the project in Code::Blocks does not change anything either. Still the same error.
NOTE: When I compile the above program using msys2 console and compile it with gcc main.c -o run_me pkg-config --cflags --libs gtk+-3.0 I get errors about -ldwmapi but I get a run_me.exe file that works just as expected. I have pasted in some different example gtk c code into the main.c file and compiled it with the msys console and it compiles & links an exe file perfectly, even manages to create gtk windows flawlessly. This is not sustainable because it is awful to code in nano inside a console that does not have auto completion.
ALL,
First apologies if this belongs to Unix/Linux part of SO. But this question has a very thin line between those 2. If you feel I should post there let me know and I will move it. So here goes:
Im trying to compile a program on Oracle Solaris that can be successfully build on Linux with Solaris Studio.
However, I'm getting a lot of linker errors with the STL fuhnctions. My guess is that the Makefile generated is for Linux/gcc and it doesn't make into account anything else.
What is the way to search for a symbol in Solaris?
The command that was generated for Makefile is:
Igor Korot
Tue, Apr 16, 7:26 PM (15 hours ago)
to wx-dev
Hi,
I'm trying to see if wxWidgets 3.1.1 can be used on Oracle Solaris with
latest Solaris Studio 12.6.
The library compiled correctly however, when I try to build minimal I got this:
igor#solaris:~/wxWidgets/buildSol/samples/minimal$ make
CC -o minimal minimal_minimal.o
-L/export/home/igor/wxWidgets/buildSol/lib
-R/export/home/igor/wxWidgets/buildSol/lib -mt -lwx_gtk3u_core-3.1
-lwx_baseu-3.1 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0
-latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0
-lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lX11 -lXxf86vm -lSM -lgtk-3
-lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo
-lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lnotify
-lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lXtst
-lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig
-lfreetype -lpng -lz -ljpeg -ltiff -llzma -lwxregexu-3.1 -mt -lz
-lsecret-1 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lm -lz -lsecret-1
-lgio-2.0 -lgobject-2.0 -lglib-2.0 -lm
And here are couple of errors it produced:
Undefined first referenced
symbol in file
std::wstring::_M_rep()const
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned int)
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
std::wstring::capacity()const
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
jpeg_resync_to_restart(jpeg_decompress_struct*, int)
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
std::streambuf::pbackfail(int)
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
std::wstring::insert(__gnu_cxx::__normal_iterator<wchar_t*,
std::wstring>, wchar_t)
/export/home/igor/wxWidgets/buildSol/lib/libwx_baseu-3.1.so
std::wstring::basic_string()
/export/home/igor/wxWidgets/buildSol/lib/libwx_baseu-3.1.so
std::wstring::basic_string() minimal_minimal.o
std::wstring::~basic_string()
/export/home/igor/wxWidgets/buildSol/lib/libwx_baseu-3.1.so
std::wstring::~basic_string() minimal_minimal.o
std::wstring::operator=(wchar_t)
/export/home/igor/wxWidgets/buildSol/lib/libwx_gtk3u_core-3.1.so
TIA!
I think it's a C++ standard library issue. There are different implementations of C++ out there. See if you can find another compiler/library that matches yours on Solaris.
I use cmake to create my project using ffmpeg lib, the project is simple.
add_executable(testffmpeg main.cpp)
link_directories( /usr/lib/x86_64-linux-gnu )
target_link_libraries(testffmpeg libavcodec.a libavutil.a )
When make, there's lots of undefined reference errors (my default cxx compiler is clang by "export cxx=/usr/bin/clang++").
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libavcodec.a(crystalhd.o): In function `receive_frame':(.text+0xef): undefined reference to `DtsProcOutputNoCopy'
but when I just use command, it's OK.
clang -o testffmpeg -lavutil -lavcodec main.cpp
while using gcc also get this error
gcc -o testffmpeg -lavutil -lavcodec main.cpp
so, how can I resolve this problem and where is the mistake?
You need add -lcrystalhd in your linker flags.
You can use code below to find all linker flags.
pkg-config --libs libavformat
-L/usr/local/lib -lavformat -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lavcodec -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lswresample -lm -lavutil -lm
I am trying to compile the examples of libhand, but I get the following output:
/usr/bin/ld: /usr/local/lib/libOgreMainStatic.a(OgreDynLib.cpp.o): undefined reference to symbol 'dlopen##GLIBC_2.1'
/usr/bin/ld: note: 'dlopen##GLIBC_2.1' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libdl.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [bend_one_finger] Error 1
make[1]: *** [CMakeFiles/bend_one_finger.dir/all] Error 2
make: *** [all] Error 2
The same thing happens when I try to compile my own example using the direction from libhand example. I believe it has something to do with the configuration file of libhand (LibHandConfig.cmake).
The same example compiles fine when I build it as a part of libhand, the problem occurs when I try to use libhand as a package (using cmake's FIND_PACKAGE() )
Not a complete answer, but just a step toward:
try to issue the following command after you got the make error:
/usr/bin/c++ CMakeFiles/example.dir/example.cc.o -o example -rdynamic -ldl -lXt /path/libs/libHand/hand_cpp/dist/libhand_hog.a /path/libs/libHand/hand_cpp/dist/libhand_renderer.a /path/libs/libHand/hand_cpp/dist/libhand_utils.a -lopencv_core -lopencv_flann -lopencv_imgproc -lopencv_highgui -lopencv_features2d -lopencv_calib3d -lopencv_cudaarithm -lopencv_cudawarping -lopencv_ml -lopencv_objdetect -lopencv_cuda -lopencv_cudafilters -lopencv_cudaimgproc -lopencv_video -lopencv_legacy -lopencv_cudaoptflow -lopencv_photo -lopencv_videostab -lopencv_ts -lopencv_cudacodec -lopencv_ocl -lopencv_superres -lopencv_cudafeatures2d -lopencv_nonfree -lopencv_stitching -lopencv_softcascade -lopencv_shape -lopencv_optim -lopencv_cudastereo -lopencv_cudabgsegm -lopencv_contrib -lopencv_bioinspired /path/libs/libHand/hand_cpp/dist/libdot_sceneloader.a /path/libs/libHand/hand_cpp/dist/libtinyxml.a /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/libOgreMainStatic.a -lzzip -lz -lfreeimage -lfreetype -lSM -lICE -lX11 -lXext -lXaw -lXrandr -ltbb /usr/local/lib/OGRE/libRenderSystem_GLStatic.a -lGLU -lGL /usr/local/lib/OGRE/libPlugin_OctreeSceneManagerStatic.a -ldl
If it succeeds than you have to manually add -ldl to the end of your libraries list ( target_link_libraries(example ${SOME_LIBS} ${OTHER_LIBS} -ldl) ). It seems that the configuration part of LibOGRE is slightly incorrect (it doesn't include a library libdl necessary to carelessly link application with it.