SDL2 Msys2 Windows X64 build - c++

Trying to build SDL2-2.0.14 on Windows with latest MSYS.
If i try to build with the minimal makefile in the root SDL directory i get the following error:
cc -g -O2 -I./include -c -o src/timer/dummy/SDL_systimer.o src/timer/dummy/SDL_systimer.c
cc -g -O2 -I./include -c -o src/video/SDL_RLEaccel.o src/video/SDL_RLEaccel.c
cc -g -O2 -I./include -c -o src/video/SDL_blit.o src/video/SDL_blit.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_0.o src/video/SDL_blit_0.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_1.o src/video/SDL_blit_1.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_A.o src/video/SDL_blit_A.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_N.o src/video/SDL_blit_N.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_auto.o src/video/SDL_blit_auto.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_copy.o src/video/SDL_blit_copy.c
cc -g -O2 -I./include -c -o src/video/SDL_blit_slow.o src/video/SDL_blit_slow.c
cc -g -O2 -I./include -c -o src/video/SDL_bmp.o src/video/SDL_bmp.c
cc -g -O2 -I./include -c -o src/video/SDL_clipboard.o src/video/SDL_clipboard.c
cc -g -O2 -I./include -c -o src/video/SDL_egl.o src/video/SDL_egl.c
src/video/SDL_egl.c:25:2: error: #error this should be not defined
25 | #error this should be not defined
| ^~~~~
In file included from src/video/SDL_egl_c.h:28,
from src/video/SDL_egl.c:36:
./include/SDL_egl.h:29:10: fatal error: EGL/egl.h: No such file or directory
29 | #include <EGL/egl.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/video/SDL_egl.o] Error 1
Solved it removing OPENGL support in include/SDL_config_windows.h:269:
#ifndef SDL_VIDEO_OPENGL_EGL
/* #define SDL_VIDEO_OPENGL_EGL 1 commented for wind64 build */
#endif
Now i've got the libSDL.a file, but if i try to build a test from the test folder:
Alessandro#DESKTOP-954PK5R MINGW64 /c/WORK/sdl_latest/SDL2-2.0.14/test
$ cc -g testkeys.c ../libSDL.a -I../include -o testkeys.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccSosm3W.o: in function `SDL_main':
C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:28: undefined reference to `SDL_LogSetPriority'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:30: undefined reference to `SDL_Init'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:31: undefined reference to `SDL_GetError'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:31: undefined reference to `SDL_LogError'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:35: undefined reference to `SDL_GetScancodeName'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:35: undefined reference to `SDL_Log'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:38: undefined reference to `SDL_Quit'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
Do i have to link something else?

Related

How to rectify `undefined reference to `MPI::Comm::Comm()'` when compiling with Makefile?

I am trying to compile a code by Makefile. I received the code from github. I tried to implement the solution from links:
[https://github.com/LLNL/scr/issues/130][1]
[https://stackoverflow.com/questions/62461718/mpi-complile-error-undefined-reference-to-mpiwinfree][2], etc.
These solutions are not working for me or they are too technical. I am sorry to say as I am not from a programming background, it is difficult for me to understand.
The make file are as follows:
Makefile.include
.SUFFIXES: .cxx .cu .f90 .o
.PHONY: docs
CUDA_INSTALL_PATH = /usr/local/cuda
DEVICE = cpu
#~ DEVICE = gpu
CXX = mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include
NVCC = nvcc -Xcompiler "-fopenmp -O3" -std=c++11 -use_fast_math -I../include
FC = mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm
#~ LFLAGS += -lmpi_cxx
ifeq ($(DEVICE),gpu)
LFLAGS += -lcudart
endif
OBJECT = ../kernel/$(DEVICE)Laplace.o ../kernel/$(DEVICE)BiotSavart.o\
../kernel/$(DEVICE)Stretching.o ../kernel/$(DEVICE)Gaussian.o\
../kernel/$(DEVICE)CoulombVdW.o
.cxx.o:
$(CXX) -c $? -o $# $(LFLAGS)
.cu.o:
$(NVCC) -c $? -o $# $(LFLAGS)
.f90.o:
$(FC) -c $? -o $#
and Makefile:
include ../Makefile.include
lib_parallel_ij: parallel_wrapper_ij.o $(OBJECT)
ar -cr libfmm.a parallel_wrapper_ij.o $(OBJECT)
ranlib libfmm.a
test_parallel_ij: test_parallel_ij.o
make lib_parallel_ij
$(FC) $? -L. -lfmm $(LFLAGS)
mpirun -np 2 ./a.out
clean:
make -C .. clean
When I am trying to compile it. It gives me the following errors:
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include -c test_parallel_ij.f90 -o test_parallel_ij.o
make lib_parallel_ij
make[1]: Entering directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c parallel_wrapper_ij.cxx -o parallel_wrapper_ij.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuLaplace.cxx -o ../kernel/cpuLaplace.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuBiotSavart.cxx -o ../kernel/cpuBiotSavart.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuStretching.cxx -o ../kernel/cpuStretching.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuGaussian.cxx -o ../kernel/cpuGaussian.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuCoulombVdW.cxx -o ../kernel/cpuCoulombVdW.o -Dcpu -lstdc++ -ldl -lm
ar -cr libfmm.a parallel_wrapper_ij.o ../kernel/cpuLaplace.o ../kernel/cpuBiotSavart.o ../kernel/cpuStretching.o ../kernel/cpuGaussian.o ../kernel/cpuCoulombVdW.o
ranlib libfmm.a
make[1]: Leaving directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include test_parallel_ij.o -L. -lfmm -Dcpu -lstdc++ -ldl -lm
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/op_inln.h:121: undefined reference to `ompi_mpi_cxx_op_intercept'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm_inln.h:23: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Graphcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Sub(bool const*) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Create_graph(int, int const*, int const*, bool) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o):/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: more undefined references to `MPI::Comm::Comm()' follow
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI8DatatypeE[_ZTVN3MPI8DatatypeE]+0x78): undefined reference to `MPI::Datatype::Free()'
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48): undefined reference to `MPI::Win::Free()'
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'test_parallel_ij' failed
make: *** [test_parallel_ij] Error 1
I am unable to solve the error. I couldn't compile the code. I will be greatly helped if I can get some clue to compile it.
Thanks a lot.
[1]: https://github.com/LLNL/scr/issues/130
[2]: MPI complile error, undefined reference to `MPI::Win::Free()

how to compile project include libcurl "undefined reference"

I'm using compile downloaded source code and try to make my c++ project but these error appear.
user1#ubuntu:~$ make
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -c my-curl.cpp -o curl.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -o my-curl-app my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [my-curl-app] Error 1
and i'm changed -L option to specified directory and add -lcurl for specified lib and result is.
user1#ubuntu:~/project0/my-curl$ make
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -c my-curl.cpp -o my-curl.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -o my-curl-cpp my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [bb-cppurl] Error 1
I and try curl-config to link libs but result still be the same.
user1#atom-linux-server:~/my-curl$ make
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -c my-curl.cpp -o my-curl.o
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -o my-curl-app my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [bb-cppurl] Error 1
You're using the build tools wrong.
1 - the -L option should specify a directory
2 - there's no -l (lowercase L) option to specify which lib to link with (perhaps from the directory -L identifies)
I move
-L/home/user1/practics/libcurl/lib -lcurl
to the tail of command
g++ -std=c++0x -g -Wall -Werror -I/home/user1/practics/libcurl/include -o my-curl-cpp my-curl.o main.o -L/home/user1/practics/libcurl/lib -lcurl
and it works.

undefined reference to `boost::system::generic_category()' [duplicate]

This question already has an answer here:
g++ undefined reference to `boost::system::system_category()'
(1 answer)
Closed 9 years ago.
I have a problem with my code.
I have such an info trying to build:
g++ -L /usr/local/boost_1_55_0 -Wall -pedantic -Iinc -c -lboost_system -pthread -lboost_thread -o obj/glo.o src/glo.cpp
g++ -L /usr/local/boost_1_55_0 -Wall -pedantic -Iinc -c -lboost_system -pthread -lboost_thread -o obj/serial.o src/serial.cpp
g++ -I /usr/local/boost_1_55_0 -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o
obj/glo.o: In function `__static_initialization_and_destruction_0(int, int)':
glo.cpp:(.text+0x15a): undefined reference to `boost::system::generic_category()'
glo.cpp:(.text+0x166): undefined reference to `boost::system::generic_category()'
glo.cpp:(.text+0x172): undefined reference to `boost::system::system_category()'
obj/glo.o: In function `boost::system::error_code::error_code()':
glo.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
and similar.
As You can see I have given
-lboost_system -pthread -lboost_thread and compiled system boost in /usr/local/boost_1_55_0
I have no idea whats happening.
Absolutely, g++ cannot find library boost_system. It should locate in /usr/local/boost_1_55_0/lib. You can add option "-v" to check the detailed error messages.
g++ -v -L/usr/local/boost_1_55_0/lib -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o
The commands should be as following:
g++ -I/usr/local/boost_1_55_0/include -Wall -pedantic -Iinc -c -o obj/glo.o src/glo.cpp
g++ -I/usr/local/boost_1_55_0/include -Wall -pedantic -Iinc -c -o obj/serial.o src/serial.cpp
g++ -L/usr/local/boost_1_55_0/lib -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o

Error when trying to compile webdis [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I'm going to use webdis but get and error on linking stage. Webdis is a web face for redis database. You can find it here: http://webd.is .
My system configuration is:
* Ubuntu Oneiric Ocelot (11.10 Alpha)
* Gcc 4.6
* Linux kernel 3.0.0-7
When I do make I get the next output:
krolik#krolik-PC:~/Projects/webdis$ make
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o webdis.o webdis.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o cmd.o cmd.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o worker.o worker.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o slog.o slog.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o server.o server.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o libb64/cencode.o libb64/cencode.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o acl.o acl.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o md5/md5.o md5/md5.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o http.o http.c
http.c: In function ‘http_response_write’:
http.c:138:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o client.o client.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o websocket.o websocket.c
websocket.c: In function ‘ws_handshake_reply’:
websocket.c:76:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o pool.o pool.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o conf.o conf.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/json.o formats/json.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/raw.o formats/raw.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/common.o formats/common.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/custom-type.o formats/custom-type.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/bson.o formats/bson.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/hiredis.o hiredis/hiredis.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/sds.o hiredis/sds.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/net.o hiredis/net.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/async.o hiredis/async.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/dict.o hiredis/dict.c
hiredis/dict.c:53:21: warning: ‘dictGenHashFunction’ defined but not used [-Wunused-function]
hiredis/dict.c:73:14: warning: ‘dictCreate’ defined but not used [-Wunused-function]
hiredis/dict.c:160:12: warning: ‘dictReplace’ defined but not used [-Wunused-function]
hiredis/dict.c:182:12: warning: ‘dictDelete’ defined but not used [-Wunused-function]
hiredis/dict.c:238:13: warning: ‘dictRelease’ defined but not used [-Wunused-function]
hiredis/dict.c:258:22: warning: ‘dictGetIterator’ defined but not used [-Wunused-function]
hiredis/dict.c:268:19: warning: ‘dictNext’ defined but not used [-Wunused-function]
hiredis/dict.c:288:13: warning: ‘dictReleaseIterator’ defined but not used [-Wunused-function]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/dump.o jansson/src/dump.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/error.o jansson/src/error.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/hashtable.o jansson/src/hashtable.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/load.o jansson/src/load.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/strbuffer.o jansson/src/strbuffer.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/utf.o jansson/src/utf.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/value.o jansson/src/value.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/variadic.o jansson/src/variadic.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o http-parser/http_parser.o http-parser/http_parser.c
cc -levent -pthread -o webdis webdis.o cmd.o worker.o slog.o server.o libb64/cencode.o acl.o md5/md5.o http.o client.o websocket.o pool.o conf.o formats/json.o formats/raw.o formats/common.o formats/custom-type.o formats/bson.o hiredis/hiredis.o hiredis/sds.o hiredis/net.o hiredis/async.o hiredis/dict.o jansson/src/dump.o jansson/src/error.o jansson/src/hashtable.o jansson/src/load.o jansson/src/strbuffer.o jansson/src/utf.o jansson/src/value.o jansson/src/variadic.o http-parser/http_parser.o
worker.o: In function `worker_main':
worker.c:(.text+0xd): undefined reference to `event_base_new'
worker.c:(.text+0x29): undefined reference to `event_set'
worker.c:(.text+0x35): undefined reference to `event_base_set'
worker.c:(.text+0x3f): undefined reference to `event_add'
worker.c:(.text+0x6b): undefined reference to `event_base_dispatch'
worker.o: In function `worker_can_read':
worker.c:(.text+0xd2): undefined reference to `event_set'
worker.c:(.text+0xe5): undefined reference to `event_base_set'
worker.o: In function `worker_on_new_client':
worker.c:(.text+0x1f5): undefined reference to `event_set'
worker.c:(.text+0x208): undefined reference to `event_base_set'
worker.c:(.text+0x212): undefined reference to `event_add'
worker.o: In function `worker_monitor_input':
worker.c:(.text+0x2b8): undefined reference to `event_set'
worker.c:(.text+0x2cb): undefined reference to `event_base_set'
worker.o: In function `worker_can_read':
worker.c:(.text+0xf5): undefined reference to `event_add'
worker.o: In function `worker_monitor_input':
worker.c:(.text+0x2e3): undefined reference to `event_add'
server.o: In function `server_start':
server.c:(.text+0x217): undefined reference to `event_reinit'
server.c:(.text+0x338): undefined reference to `event_base_new'
server.c:(.text+0x35a): undefined reference to `event_set'
server.c:(.text+0x369): undefined reference to `event_base_set'
server.c:(.text+0x373): undefined reference to `event_add'
server.c:(.text+0x37f): undefined reference to `event_base_dispatch'
http.o: In function `http_can_write':
http.c:(.text+0x63): undefined reference to `event_set'
http.c:(.text+0x76): undefined reference to `event_base_set'
http.o: In function `http_schedule_write':
http.c:(.text+0x3f1): undefined reference to `event_set'
http.c:(.text+0x404): undefined reference to `event_base_set'
http.o: In function `http_response_write':
http.c:(.text+0x6b1): undefined reference to `event_set'
http.c:(.text+0x6c4): undefined reference to `event_base_set'
http.c:(.text+0x6ce): undefined reference to `event_add'
http.o: In function `http_response_write_chunk':
http.c:(.text+0xc36): undefined reference to `event_set'
http.c:(.text+0xc49): undefined reference to `event_base_set'
http.c:(.text+0xc53): undefined reference to `event_add'
http.o: In function `http_can_write':
http.c:(.text+0x84): undefined reference to `event_add'
http.o: In function `http_schedule_write':
http.c:(.text+0x40f): undefined reference to `event_add'
pool.o: In function `redisLibeventCleanup':
pool.c:(.text+0x89): undefined reference to `event_del'
pool.c:(.text+0x95): undefined reference to `event_del'
pool.o: In function `pool_on_disconnect':
pool.c:(.text+0x179): undefined reference to `event_set'
pool.c:(.text+0x189): undefined reference to `event_base_set'
pool.o: In function `redisLibeventAttach':
pool.c:(.text+0x266): undefined reference to `event_set'
pool.c:(.text+0x281): undefined reference to `event_set'
pool.c:(.text+0x28c): undefined reference to `event_base_set'
pool.c:(.text+0x297): undefined reference to `event_base_set'
pool.o: In function `pool_can_connect':
pool.c:(.text+0x3dd): undefined reference to `event_set'
pool.c:(.text+0x3ed): undefined reference to `event_base_set'
pool.o: In function `pool_connect':
pool.c:(.text+0x595): undefined reference to `event_set'
pool.c:(.text+0x5a5): undefined reference to `event_base_set'
pool.c:(.text+0x5b6): undefined reference to `event_add'
pool.o: In function `redisLibeventAddWrite':
pool.c:(.text+0x6a): undefined reference to `event_add'
pool.o: In function `redisLibeventAddRead':
pool.c:(.text+0x77): undefined reference to `event_add'
pool.o: In function `redisLibeventDelWrite':
pool.c:(.text+0xb8): undefined reference to `event_del'
pool.o: In function `redisLibeventDelRead':
pool.c:(.text+0xc5): undefined reference to `event_del'
pool.o: In function `pool_on_disconnect':
pool.c:(.text+0x19e): undefined reference to `event_add'
pool.o: In function `pool_can_connect':
pool.c:(.text+0x402): undefined reference to `event_add'
collect2: ld returned 1 exit status
make: *** [webdis] Помилка 1
I have libevent.so and libevent-dev headers installed in my /usr/lib directory and I also tried -levent2 instead of -levent in LDFLAGS variable of Makefile but still didn't got any progress. What can be the solution for my issue?
Thank you.
You need to put the -levent command line option after the names of the object files in the linker command line. From the GCC documentation on the -l flag:
-llibrary
-l library
Search the library named library when linking. (The second
alternative with the library as a separate argument is only for
POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in the
order they are specified. Thus, foo.o -lz bar.o searches library z
after file foo.o but before bar.o. If bar.o refers to functions in
z, those functions may not be loaded.

undefined reference when linking against libresolv

I have a project that is a library that links against libresolv,
It works fine on recent distros: Ubuntu 10.x Fedora 13, Mandriva
2010.1 but on Centos 5.x I get the following errors
glibc installed is: glibc-2.5-18.el5_1.1
g++ -DHAVE_CONFIG_H -I. -I./include -I/usr/include/postgresql -O3
-ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0 -MT testUpLog.o -MD
-MP -MF .deps/testUpLog.Tpo -c -o testUpLog.o testUpLog.cc
mv -f .deps/testUpLog.Tpo .deps/testUpLog.Po
/bin/sh ./libtool --tag=CXX --mode=link g++ -O3 -ansi -Wall
-Wno-deprecated -D_FORTIFY_SOURCE=0 -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql -o testUpLog testUpLog.o libUpTools.la -lpq
-lmysqlclient -lssl -lpthread
libtool: link: g++ -O3 -ansi -Wall -Wno-deprecated -D_FORTIFY_SOURCE=0
-o .libs/testUpLog testUpLog.o -L/usr/lib64 -L/lib64
-L/usr/lib64/mysql ./.libs/libUpTools.so -lpq -lmysqlclient -lssl
-lpthread
./.libs/libUpTools.so: undefined reference to `__ns_name_uncompress'
./.libs/libUpTools.so: undefined reference to `__ns_initparse'
./.libs/libUpTools.so: undefined reference to `__ns_parserr'
collect2: ld returned 1 exit status
make[1]: *** [testUpLog] Error 1
make[1]: Leaving directory `/tmp/UpTools-8.5.3'
make: *** [check-am] Error 2
library.la file contains:
dlname='libUpTools.so.0'
library_names='libUpTools.so.0.0.0 libUpTools.so.0 libUpTools.so'
old_library='libUpTools.a'
inherited_linker_flags=''
dependency_libs=' -L/usr/lib64 -L/lib64 -L/usr/lib64/mysql -lpq
-lmysqlclient -lssl -lpthread'
weak_library_names=''
current=0
age=0
revision=0
installed=no
shouldnotlink=no
dlopen=''
dlpreopen=''
libdir='/usr/lib'
You can read configure.ac on
http://pastebin.com/hs5q21Rq
Thanks in advance
If libUpTools uses functions lib libresolv, you need to say so:
libUpTools_la_LIBADD = -lresolv (of course -lresolv may be replaced by variables determined by configure etc.)
That way, -lresolv will end up in the .la file and also in the .so file (if you chose to build it) that you can run ldd on for verification.