[Coin-bcpdiscuss] Link problems

Laszlo Ladanyi ladanyi at us.ibm.com
Tue Jan 9 13:55:30 EST 2007


Sounds a stupid question, but do you have a main() function? 

BCP has switched to being a library some time ago, so that the user can do
things before bcp fires up. (Otherwise it behaves the same way it used to,
that is, currently it's impossible to extract the tree or anything after bcp
finishes :-(. All you have is the output.) This means that the user has to
write the main() function.

--Laci

On Tue, 9 Jan 2007, Carlos Eduardo de Andrade wrote:

> Hellow,
> 
> I'm having problems to link my code. The error is
> 
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function `_start':
> (.text+0x18): undefined reference to `main'
> 
> i.e., the linker can't find the main(). My compilation command is
> 
> g++ -g <objs>  -L/home/carlos/software/coin/lib -lBcp -lOsiGlpk -lOsi
> -L/usr/lib -lglpk -lCoinUtils  `cat
> /home/carlos/software/coin/lib/bcp_addlibs.txt` `cat
> /home/carlos/software/coin/lib/osi_addlibs.txt` `cat
> /home/carlos/software/coin/lib/coinutils_addlibs.txt` -o spp
> 
> I think that problem is the order of the libs. I tried many
> combinations but nothing.
> It's funny because BAC example works correctly, say, compile and link
> correctly. My Makefile is almost identical. See you:
> 
> USER_DEFINES = -DLINUX
> USER_FLAGS = -g
> COINDIR = /home/carlos/software/coin
> SOLVER = GLPK
> USER_DEFINES += -DCOIN_USE_$(SOLVER)
> EXE = spp
> 
> OBJS = \
> 	./Member/item1d.o \
> 	./Member/item2d.o \
> 	./Member/compoundeditem.o \
> 	./Member/spp.o \
> 	./Member/SPP_user_data.o \
> 	./Member/SPP_var.o \
> 	./Member/SPP_init.o \
> 	./Member/SPP_vargen_by_knapsack.o \
> 	./Member/SPP_vargen_by_mip_solver.o \
> 	./Member/SPP_vargen_by_combinations.o \
> 	./Member/SPP_heuristic_gen.o \
> 	./Member/testunit.o \
> 	./TM/SPP_tm.o \
> 	./TM/SPP_tm_param.o \
> 	./LP/SPP_lp.o \
> 	./LP/SPP_lp_branch.o \
> 	./LP/SPP_lp_param.o \
> 	./LP/SPP_lp_vargen.o
> 
> USER_INCDIRS = include
> USER_OSI_LIBS = -lOsiGlpk
> USER_SOLVER_LIBS = -L$(GLPK_LIB_DIR) -lglpk
> USER_INCDIRS += $(GLPK_INC_DIR)
> USER_EXTRA_LIBS =
> 
> CXX = g++
> CXXFLAGS = $(USER_FLAGS)
> CXXLINKFLAGS =
> 
> COININCDIR = $(COINDIR)/include
> COINLIBDIR = $(COINDIR)/lib
> 
> LIBS = \
> 	-L$(COINLIBDIR) \
> 	-lBcp \
> 	$(USER_OSI_LIBS) \
> 	-lOsi \
> 	$(USER_SOLVER_LIBS) \
> 	-lCoinUtils \
> 	$(USER_EXTRA_LIBS) \
> 	`cat $(COINLIBDIR)/bcp_addlibs.txt` \
> 	`cat $(COINLIBDIR)/osi_addlibs.txt` \
> 	`cat $(COINLIBDIR)/coinutils_addlibs.txt`
> 
> INCLUDES = `for i in $(USER_INCDIRS) $(COININCDIR); do echo $$i | sed
> -e 's/^/-I/'; done`
> 
> all: $(EXE)
> 
> .SUFFIXES: .cpp .o
> 
> $(EXE): $(OBJS)
> 	$(CXX) $(CXXFLAGS) $(CXXLINKFLAGS) $(OBJS) $(LIBS) -o $@
> 
> .cpp.o:
> 	$(CXX) $(CXXFLAGS) $(INCLUDES) $(USER_DEFINES) -c $< -o $@
> 
> clean:
> 	rm -rf $(EXE) $(OBJS)
> 
> 
> I tried to use the Makefile example, but it don't work too. Do
> Somebody have an ideia?!?!
> 
> Thanks for all,
> 
> Carlos
> 
> p.s.: sorry my English
> -- 
> Carlos Eduardo de Andrade
> Escola Agrotecnica Federal de Inconfidentes
> Brazil
> _______________________________________________
> Coin-bcpdiscuss mailing list
> Coin-bcpdiscuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-bcpdiscuss
> 




More information about the Coin-bcpdiscuss mailing list