What would cause the following Linker Error when compiling C++ XSDK project??
Linker Error Message:
./src/platform/platform_zynq.o: In function `timer_callback(XScuTimer*)':
platform_zynq.c:115:undefined reference to `dhcp_fine_tmr()'
platform_zynq.c:117:undefined reference to `dhcp_coarse_tmr()'
collect2.exe: error: ld returned 1 exit status
make: *** [uartcmd.elf] Error 1
Linker Command as follows:
arm-none-eabi-g++ \
-mcpu=cortex-a9 \
-mfpu=vfpv3 \
-mfloat-abi=hard \
-Wl,-build-id=none \
-specs=Xilinx.spec \
-Wl,-T\
-Wl,../src/lscript.ld \
-L../../uartcmd_bsp/ps7_cortexa9_0/lib \
-o "uartcmd.elf" \
./src/platform/platform.o \
./src/platform/platform_mb.o \
./src/platform/platform_ppc.o \
./src/platform/platform_zynq.o \
./src/platform/platform_zynqmp.o \
./src/fpga_registers2.clang.o \
./src/main.o \
./src/network.o \
-Wl,\
--start-group,-lxil,-lfreertos,-lgcc,-lc,-lstdc++,--end-group\
-Wl,--start-group,-lxil,-llwip4,-lgcc,-lc,--end-group
Configured Xilinx SDK project as follows:
// Step 0: Create Application Project with FreeRTOS Selected
//
// Step 1: Adding lwIP library to XSDK project.
//
// (2) Right click <app>_bsp and select
// "Board Support Package Settings"
// (3) Click Check box "lwip"
//
// Step 2: Add DHCP Support
// (1) Right click <app>_bsp and select
// "Board Support Package Settings"
// (2) Click Overview:freertos901_xilinx.lwip141
// (3) Check dhcp_options.dhcp_does_arp_check true
// (4) Check dhcp_options.lwip_dhcp true
Symbol Table as Follows:
$ nm ./zynq_rtl.sdk/uartcmd_bsp/ps7_cortexa9_0/lib/liblwip4.a | grep -i dhcp_fine
00001c7c T dhcp_fine_tmr
$ nm ./zynq_rtl.sdk/uartcmd_bsp/ps7_cortexa9_0/lib/liblwip4.a | grep -i dhcp_coarse
00001a54 T dhcp_coarse_tmr
$ nm -C ./uartcmd/Debug/src/platform/platform_zynq.o | grep dhcp_fine
U dhcp_fine_tmr()
$ nm -C ./uartcmd/Debug/src/platform/platform_zynq.o | grep dhcp_coarse
U dhcp_coarse_tmr()
Doesn't look like name mangle problem to me... I add "-C" option to prevent demangling of the symbol names...
Related
This is my makefile in linux
.SILENT:
.SUFFIXES: .cpp
FLAGS_CC = -c -fPIC -DUNIX -DLINUX -D_HNAREL_=500 -D_TARGET__REL=0 -D_TARGET__DEBUG=1 -D_ILS_MACROS -I$(cer_incl)
FLAGS_CPP = -c -Wno-deprecated -fPIC -frtti -finline-functions -DUNIX -DLINUX -D_HNAREL_=500 -D_TARGET__REL=0 -D_TARGET__DEBUG=1 -D_ILS_MACROS -I$(cer_incl)
FLAGS_LINK = -m32 -fPIC -lm -lc -lrt -lpthread -ldl
FLAGS_LINKSHR = -m32 -lm -lc -shared -Wl,-no-undefined -lrt -lpthread -ldl
CC = gcc $(FLAGS_CC) $(__define) $(__build)
CPP = g++ $(FLAGS_CPP) $(__define) $(__build)
LINK = g++ $(FLAGS_LINK)
LINKSHR = g++ $(FLAGS_LINKSHR)
PRINT = echo
##
## The following environment variables are defined for your convenience.
##-----
## __srcdir - Project directory that contains the makefile and source code.
## __objdir - Project subdirectory that stores objects for the given platform
## and target combination.
## __libdir - Public directory that contains objects and shareable libraries.
## __exedir - Public directory that contains executables.
##-----
## Please do not delete the following line!
###makefile###
###makedep###
#my_project.o
FLAGS__MY_PROJECT =
DEFINES__MY_PROJECT =
my_project.o: $(__objdir)/my_project.o
$(__objdir)/my_project.o: \
my_project.cpp \
$(cer_incl)/srvimpl.h \
$(PRINT) "compiling - my_project.cpp"
[[ -d $(__objdir) ]] || mkdir -p $(__objdir)
$(CPP) $(FLAGS__MY_PROJECT) $(DEFINES__MY_PROJECT) -o $(__objdir)/my_project.o my_project.cpp
#aps_s200061.o
FLAGS__APS_S200061 =
DEFINES__APS_S200061 =
aps_s200061.o: $(__objdir)/aps_s200061.o
$(__objdir)/aps_s200061.o: \
aps_s200061.cpp \
aps_s200061.h \
$(cer_incl)/srvimpl.h \
$(PRINT) "compiling - aps_s200061.cpp"
[[ -d $(__objdir) ]] || mkdir -p $(__objdir)
$(CPP) $(FLAGS__APS_S200061) $(DEFINES__APS_S200061) -o $(__objdir)/aps_s200061.o aps_s200061.cpp
###makedep###
FLAGS_CPP += -D__RHEL6
FLAGS__APS_S200061 =
objects: my_project.o aps_s200061.o
my_project : objects
$(PRINT) "creating - my_project "
$(LINKSHR) \
-Wl,--version-script=$(__srcdir)/my_project.emap \
-o $(__objdir)/my_project \
$(__objdir)/my_project.o \
$(__objdir)/aps_s200061.o \
-Wl,--start-group \
-L$(__libdir) -lapsobj -lcernobj -lcontainerobj -lstringobj -li18n_common -lmsgutilobj -lmftmiscobj -lsrvcoreobj -lcrmobj -lthreadobj \
-Wl,--whole-archive -lsrvobj -Wl,--no-whole-archive \
-Wl,--end-group \
-L$(__exedir) -ldb -ldps -lsrv -lsec \
-lcclora -lreg -lmsgapi -ldate \
-llogical -lsrvcore -lcrm
copy:
$(PRINT) "copying - my_project"
cp $(__objdir)/my_project $(__exedir)
it: my_project copy
# shr:my_project
I want to remove the command cp $(__objdir)/my_project $(__exedir) from the above file.
When I try removing the line manually in a text editor and save it , the make file doesn't throw any errors.
But if I try removing the line programmatically , we get make: *** No rule to make target my_project.o', needed by objects'. Stop.
Sequence of commands we use is :
'makedep'
'make -f ${PWD##*/}.linux -r __target=rel _define="-D_TARGET=_TARGET__REL " __srcdir=$PWD __objdir=$PWD/linuxx86-64 __libdir=$abc_lib_rel __exedir=$abc_exe_rel __build="-O3" it'
I'm trying to set up MaxHS SAT solver from this git repo - https://github.com/fbacchus/MaxHS.
I get an error that says '/usr/bin/ld: cannot find -lcplex'.
Can anyone guide me on what is lcplex library and how to fix this?
My console looks like this..
install -d /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/maxhs
install -d /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/minisat
for dir in maxhs/core maxhs/ifaces maxhs/ds maxhs/utils; do \
install -d /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/$dir ; \
done
for dir in minisat/mtl minisat/utils minisat/core minisat/simp; do \
install -d /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/$dir ; \
done
for h in minisat/mtl/Alg.h minisat/mtl/Map.h minisat/mtl/Alloc.h
minisat/mtl/Vec.h minisat/mtl/Rnd.h minisat/mtl/Sort.h minisat/mtl/IntMap.h
minisat/mtl/Queue.h minisat/mtl/IntTypes.h minisat/mtl/Heap.h
minisat/mtl/XAlloc.h minisat/core/SolverTypes.h minisat/core/Dimacs.h
minisat/core/Solver.h minisat/utils/System.h minisat/utils/ParseUtils.h
minisat/utils/Options.h minisat/simp/SimpSolver.h ; do \
install -m 644 $h /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/$h ; \
done
for h in maxhs/core/Bvars.h maxhs/core/Dimacs.h maxhs/core/MaxSolverTypes.h
maxhs/core/Assumptions.h maxhs/core/Wcnf.h maxhs/core/MaxSolver.h
maxhs/ifaces/miniSatSolver.h maxhs/ifaces/GreedySolver.h
maxhs/ifaces/Cplex.h maxhs/ifaces/greedySatSolver.h maxhs/ifaces/muser.h
maxhs/ifaces/SatSolver.h maxhs/ds/Packed.h maxhs/utils/io.h
maxhs/utils/Params.h maxhs/utils/hash.h ; do \
install -m 644 $h /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/include/$h ; \
done
install -d /mnt/c/Akhil/Abhyas/CQA/maxhs_installation/lib
install -m 644 build/release/lib/libmaxhs.a
/mnt/c/Akhil/Abhyas/CQA/maxhs_installation/lib
Linking Binary: build/release/bin/maxhs
/usr/bin/ld: cannot find -lcplex
collect2: error: ld returned 1 exit status
Makefile:155: recipe for target 'build/release/bin/maxhs' failed
make: *** [build/release/bin/maxhs] Error 1
Linking Binary: build/release/bin/maxhs
/usr/bin/ld: cannot find -lcplex
This says that linker is unable to find libcplex.so
You need to give path of this library something like -L/pathtolibrary
I received the following error in the logs while I was trying to build glibc:
configure:3180: checking whether g++ can link programs
configure:3203: g++ -o conftest -g -O2 conftest.cpp >&5
configure:3203: $? = 0
configure:3226: g++ -o conftest -g -O2 -static conftest.cpp >&5
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lm
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
configure:3226: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| #define PACKAGE_URL "http://www.gnu.org/software/glibc/"
| #define PKGVERSION "(GNU libc) "
| #define REPORT_BUGS_TO "<http://www.gnu.org/software/libc/bugs.html>"
| /* end confdefs.h. */
|
| #include <iostream>
|
| int
| main()
| {
| std::cout << "Hello, world!";
| return 0;
| }
|
configure:3241: result: no
configure:3248: error: you must configure in a separate build directory
Any ideas how to fix it?
How to reproduce it:
Download the glibc from here and try to make ./configure.
I think the error itself if is a good hint? It says you should configure in a build directory, so make a directory called build in the top source directory and cd to it then run ../configure.
I'm compiling sipXtapi and I need to compile with this line
gcc -shared -DPIC .libs/codec_pcmapcmu_la-CodecPcmaWrapper.o .libs/codec_pcmapcmu_la-CodecPcmuWrapper.o .libs/codec_pcmapcmu_la-G711.o .libs/codec_pcmapcmu_la-PlgPcmaPcmu.o -lc -W1,-soname=codec_pcmapcmu.so -o .libs/codec_pcmapcmu.so
gcc: error: unrecognized command line option ‘-W1,-soname=codec_pcmapcmu.so’
and this is the Makefile.am:
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/../sipXportLib/include -I$(top_srcdir)/contrib/libspandsp/src
pkgdata_LTLIBRARIES = codec_pcmapcmu.la
codec_pcmapcmu_la_SOURCES = \
CodecPcmaWrapper.c \
CodecPcmuWrapper.c \
G711.c \
PlgPcmaPcmu.c
if PCMAPCMU_STATIC
codec_pcmapcmu_la_CFLAGS = -DCODEC_STATIC
codec_pcmapcmu_la_LDFLAGS = -module -avoid-version -static else
codec_pcmapcmu_la_LDFLAGS = -module -avoid-version
all-local: codec_pcmapcmu.la
echo "Installing plugin codec_pcmapcmu.so ..."
cp -f .libs/codec_pcmapcmu.so #DEFAULT_CODECS_PATH#
clean-local:
rm -f #DEFAULT_CODECS_PATH#/codec_pcmapcmu.so endif
how can I solve the problem?
There's a spelling error there -W1 should be -Wl (that's a lower case L instead of the digit 1)
When linking some object files together I get a bunch of errors like:
obj-ia32/ShadowRoutine.o: In function `InitializeMap(unsigned int*)':
ShadowRoutine.cpp:(.text+0x0): multiple definition of `InitializeMap(unsigned int*)'
obj-ia32/ShadowRoutine.o:ShadowRoutine.cpp:(.text+0x0): first defined here
with compilation and linking commands of:
g++ -DBIGARRAY_MULTIPLIER=1 -Wall -Wno-unknown-pragmas -fno-stack-protector \
-DTARGET_IA32 -DHOST_IA32 -DTARGET_LINUX -I../../../source/include/pin \
-I../../../source/include/pin/gen -I../../../extras/components/include \
-I../../../extras/xed-ia32/include -I../../../source/tools/InstLib -O3 \
-fomit-frame-pointer -fno-strict-aliasing -Wno-unused-variable \
-Wno-unused-function -I. -Ishadow-memory -m32 -c \
-o obj-ia32/ShadowRoutine.o ShadowRoutine.cpp
g++ -DBIGARRAY_MULTIPLIER=1 -Wall -Wno-unknown-pragmas -fno-stack-protector \
-DTARGET_IA32 -DHOST_IA32 -DTARGET_LINUX -I../../../source/include/pin \
-I../../../source/include/pin/gen -I../../../extras/components/include \
-I../../../extras/xed-ia32/include -I../../../source/tools/InstLib -O3 \
-fomit-frame-pointer -fno-strict-aliasing -Wno-unused-variable \
-Wno-unused-function -I. -Ishadow-memory -m32 -c \
-o obj-ia32/Jikes.o Jikes.cpp
g++ -shared -Wl,--hash-style=sysv -Wl,-Bsymbolic \
-Wl,--version-script=../../../source/include/pin/pintool.ver \
-m32 -o obj-ia32/Jikes.so obj-ia32/ClientReq.o obj-ia32/Server.o \
obj-ia32/ShadowRoutine.o obj-ia32/FncnMap.o obj-ia32/Trace.o \
obj-ia32/Jikes.o obj-ia32/ClientReq.o obj-ia32/Server.o \
obj-ia32/ShadowRoutine.o obj-ia32/FncnMap.o obj-ia32/Trace.o \
-L../../../ia32/lib -L../../../ia32/lib-ext -L../../../ia32/runtime/glibc \
-L../../../extras/xed-ia32/lib \
-L/home/karl/r/git/pin/source/tools/Jikes/zmq/inst/lib \
-lpin -lxed -lpindwarf -ldl -lzmq
The only two object files with InitializeMap are Jikes.o and ShadowRoutine.o:
$ nm obj-ia32/Jikes.o | grep InitializeMap
U _Z13InitializeMapPj
$ nm obj-ia32/ShadowRoutine.o | grep InitializeMap
00000000 T _Z13InitializeMapPj
$ nm obj-ia32/* | grep InitializeMap
U _Z13InitializeMapPj
00000000 T _Z13InitializeMapPj
So why am I getting "multiple definitions of InitializeMap" if it's only "defined" in one object file and "undefined" in the only other object file that required it using extern?
This is what the declarations, definitions, and uses look like:
$ grep -r InitializeMap *
Jikes.cpp: if (rtn_name == "sysInitializeMap") { RTN_INSERT_1(InitializeMap);
Binary file obj-ia32/Jikes.o matches
Binary file obj-ia32/ShadowRoutine.o matches
ShadowRoutine.cpp:VOID InitializeMap(ADDRINT *smID) { init_map(*(int*)smID); }
ShadowRoutine.hpp:VOID InitializeMap(ADDRINT *smID);
where both the cpp files #include "ShadowRoutine.hpp".
EDIT: My question is why does the linker command (the third g++ command in the second code snippet above) not work even though nm says that the function is only defined in the text of ShadowRoutine.o and undefined in Jikes.o?
You have the file obj-ia32/ShadowRoutine.o listed twice in your link command.