gcc - C compilation error, external library functions not found -
i'm trying compile project (which written on 32bit os, ubuntu). i'm using given makefiles
, installed necessary external libraries (on 64bit ubuntu).
i don't library linking error functions implemented in sdl
, argtable2
(external libraries) not recognized. changed path libsdl_gfx.so
points 64bit installation.
how can solve compilation issue?
code:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <argtable2.h> #include "../../problems/generative_model.h" #include "../../problems/viewer.h" #include "opcas.h" int main(int argc, char* argv[]) { double discountfactor; unsigned int maxnbevaluations; char isterminal = 0; char isdisplayed = 1; char verbose = 0; unsigned int nbtimestep = 0; double l; opcas_instance* instance = null; state* crtstate = null; state* nextstate = null; double reward = 0.0; double* optimalaction = null; struct arg_dbl* g = arg_dbl1("g", "discountfactor", "<d>", "the discount factor problem"); ... return exit_success; }
the makefile looks like:
cc := gcc flags := -w -wall -g -ansi -std=c99 -pedantic libs := -lm -lsdl -lsdlmain /usr/lib/x86_64-linux-gnu/libsdl_gfx.so -largtable2 bin_dir := bin obj_dir := obj all: $(bin_dir)/opcas_ball $(bin_dir)/opcas_inverted_pendulum $(bin_dir)/opcas_mountain_car $(bin_dir)/opcas_acrobot $(bin_dir)/opcas_spring_pendulum $(bin_dir)/opcas_ball: $(obj_dir)/opcas_1.o $(obj_dir)/main_opcas_1.o $(obj_dir)/ball.o $(obj_dir)/viewer_ball.o $(obj_dir)/opcas_drawing_procedure_ball.o $(obj_dir)/svgfile.o $(cc) $(flags) $(libs) $^ -o $@
the error (similar error sdl functions):
gcc -w -wall -g -ansi -std=c99 -pedantic -lm -lsdl -lsdlmain /usr/lib/x86_64-linux- gnu/libsdl_gfx.so -largtable2 obj/opcas_1.o obj/main_opcas_1.o obj/ball.o obj/viewer_ball.o obj/opcas_drawing_procedure_ball.o obj/svgfile.o -o bin/opcas_ball obj/main_opcas_1.o: in function `main': /home/elod/utwork/realtime_cpp/continuous_action_space/algorithms/opcas/main_opcas.c:63: undefined reference `arg_dbl1'
options specifying libraries need go command-line after object using symbols out of libraries given.
so command:
gcc -w -wall -g -ansi -std=c99 -pedantic -lm -lsdl -lsdlmain /usr/lib/x86_64-linux-gnu/libsdl_gfx.so -largtable2 obj/opcas_1.o obj/main_opcas_1.o obj/ball.o obj/viewer_ball.o obj/opcas_drawing_procedure_ball.o obj/svgfile.o -o bin/opcas_ball
should this
gcc -w -wall -g -ansi -std=c99 -pedantic /usr/lib/x86_64-linux-gnu/libsdl_gfx.so obj/opcas_1.o obj/main_opcas_1.o obj/ball.o obj/viewer_ball.o obj/opcas_drawing_procedure_ball.o obj/svgfile.o -o bin/opcas_ball -lm -lsdl -lsdlmain -largtable2
as rule of thumb, work in cases: place -lxyz
options @ end of link command.
Comments
Post a Comment