Linker can't find -lgcc [CMU Malloc Lab] - c++

I'm trying to make the following makefile code
#
# Students' Makefile for the Malloc Lab
#
TEAM = bovik
VERSION = 1
HANDINDIR = /afs/cs.cmu.edu/academic/class/15213-f01/malloclab/handin
CC = gcc
CFLAGS = -Wall -O2 -m32
OBJS = mdriver.o mm.o memlib.o fsecs.o fcyc.o clock.o ftimer.o
mdriver: $(OBJS)
$(CC) $(CFLAGS) -o mdriver $(OBJS)
mdriver.o: mdriver.c fsecs.h fcyc.h clock.h memlib.h config.h mm.h
memlib.o: memlib.c memlib.h
mm.o: mm.c mm.h memlib.h
fsecs.o: fsecs.c fsecs.h config.h
fcyc.o: fcyc.c fcyc.h
ftimer.o: ftimer.c ftimer.h config.h
clock.o: clock.c clock.h
handin:
cp mm.c $(HANDINDIR)/$(TEAM)-$(VERSION)-mm.c
clean:
rm -f *~ *.o mdriver
but get an error message
gcc -Wall -O2 -m32 -o mdriver mdriver.o mm.o memlib.o fsecs.o fcyc.o clock.o ftimer.o
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
Makefile:14: recipe for target 'mdriver' failed
make: *** [mdriver] Error 1
Things that I have tried include:
Install gcc-multilib, libc6-i386, libc6-dev-i386 lib32gcc1, lib32stdc++6,libc6-dev-i386
export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/usr/lib/i386-linux-gnu
In my system, there is no libgcc.so file but libgcc_s.so and libgcc_s.so.1. Can someone help me with it?

Related

Compile a c++ program on PC to communicate with DJI phantom 4 pro

I am trying to receive on my PC(linux mint), a streaming from the camera of a DJI phantom 4 using OpenCV.
The example I am following is : https://developer.dji.com/guidance-sdk/documentation/tutorials/index.html (I am following the linux part)
I copied the Copy libDJI_guidance.so in /usr/local/lib and I checked, it is there.
The makefile is :
#define a compiler
CXX = g++
#define target name
TARGET = main
#define dependencies of target
OBJECTS = main.o DJI_utility.o
#define the Include and Library path
CFLAGS = -g -Wall -I/usr/local/include -I../../../include
LDFLAGS = -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 `pkg-config --cflags --libs opencv`
$(TARGET) : $(OBJECTS)
$(CXX) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
main.o : main.cpp DJI_utility.h
$(CXX) $(CFLAGS) -c main.cpp DJI_utility.h
DJI_utility.o : DJI_utility.cpp DJI_utility.h
$(CXX) $(CFLAGS) -c DJI_utility.cpp DJI_utility.h
clean:
rm -rf *.o *.gch *.avi $(TARGET)
But when i excute a make in the command line i get:
g++ -o main main.o DJI_utility.o -Wl,-rpath,./ -lpthread -lrt -L./ -L/usr/local/lib/ -lDJI_guidance -lusb-1.0 `pkg-config --cflags --libs opencv`
/usr/bin/ld: skipping incompatible /usr/local/lib//libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: skipping incompatible /usr/local/lib/libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: skipping incompatible //usr/local/lib/libDJI_guidance.so when searching for -lDJI_guidance
/usr/bin/ld: cannot find -lDJI_guidance
/usr/bin/ld: cannot find -lusb-1.0
collect2: error: ld returned 1 exit status
Makefile:12: recipe for target 'main' failed
make: *** [main] Error 1
The project is located in:
~/Documents/studies_SRT/SRT5/TX_drone/Guidance-SDK/demo/guidance_track
The output of an ls is:
DJI_guidance.h DJI_utility.cpp DJI_utility.h DJI_utility.h.gch DJI_utility.o main.cpp main.o Makefile
Thank you.
You seem to have downloaded library files for the wrong architecture. If you're on a 64-bit system, download the 64-bit version of the libraries.

RInside and Qt examples compilation error

I'm new about RInside and I want to run the examples about QT
I get this error all the time I use "qmake" and "make" as say the README, and I really want to know what can I do about it.
$ g++ -Wl,-O1 -o qtdensity qtdensity.o main.o moc_qtdensity.o -L/usr/lib/i386-linux-gnu -Wl,--export-dynamic -fopenmp -L/usr/lib/R/lib -lR -lpcre -llzma -lbz2 -lrt -ldl -lm -lblas -llapack -L/home/user/R/i686-pc-linux-gnu-library/3.1/RInside/lib -lRInside -Wl,-rpath,/home/user/R/i686-pc-linux-gnu-library/3.1/RInside/lib -lQtSvg -lQtGui -lQtCore -lpthread
/usr/bin/ld: cannot find -llzma
collect2: ld devolvió el estado de salida 1
make: *** [qtdensity] Error 1
I thought it was because I had not the library lzma, but I intalled it and I still get the same error.
What can I do? Can you help me please?

Linker error in the makefile using OpenGL

While compiling my project using OpenGL and wxWidgets under ubuntu 14.04, i got this error (to link the .o):
cc GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt -o GUI
/usr/bin/ld: GUI.o: référence au symbole non défini «__cxa_pure_virtual##CXXABI_1.3»
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [GUI] Erreur 1
I installed all the libraries (freeglut3, freeglut3 -dev, ...)
here is my makefile:
CXX=g++-4.8
CXXFLAGS += `wx-config --cxxflags` -std=c++11
CXXFLAGS += -g
LDLIBS += `wx-config --libs gl,core,base` -lGLU -lGL -lglut -lrt
TARGETS=GUI
all:: $(TARGETS)
Fenetre.o : Fenetre.cc Fenetre.h
GUI.o : GUI.cc GUI.h
Vue_OpenGL.o : Vue_OpenGL.cc Vue_OpenGL.h
Vecteur.o: Vecteur.cc Vecteur.h
Systeme.o: Systeme.cc Systeme.h GenerateurAleatoire.h
Particule.o: Particule.cc Particule.h
GLArgon.o: GLArgon.cc GLArgon.h
GLNeon.o: GLNeon.cc GLNeon.h
Enceinte.o: Enceinte.h Enceinte.cc
GUI : GUI.o Fenetre.o Vue_OpenGL.o Enceinte.o Systeme.o GLNeon.o GLArgon.o Particule.o Vecteur.o
You must use c++, not cc, to link the C++ programs. To do this, you need to define the recipe for linking explicitly instead of relying on the implicit one, i.e.
GUI.o: $(OBJECTS)
$(CXX) -o $# $(LDFLAGS) $(OBJECTS) $(LIBS)

/usr/bin/ld: cannot find -lgd

So I am trying to compile a program using make -f Makefile but I am getting this error /usr/bin/ld: cannot find -lgd
root#kevin-VirtualBox://home/kevin/Desktop/makef# make -f Makefile
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld: cannot find -lgd
collect2: ld returned 1 exit status
make: *** [main] Error 1
root#kevin-VirtualBox://home/kevin/Desktop/makef#
Makefile:
IDIR =./
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=obj
LDIR =./
LIBS=-lgd -lrt
_DEPS = main.h Makefile
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $# $< $(CFLAGS)
main: $(OBJ)
gcc -o $# $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~
after replacing (libgd.a libgd.la libgd.so libgd.so.2 libgd.so.2.0.0) I am getting this error:
root#kevin-VirtualBox://home/kevin/Desktop/makef# make -f Makefilegcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/../lib/libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../libgd.a when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/libgd.so when searching for -lgd
/usr/bin/ld: skipping incompatible /usr/lib/libgd.a when searching for -lgd
/usr/bin/ld: cannot find -lgd
collect2: ld returned 1 exit status
make: *** [main] Error 1
You should have package libgd-dev (or libgd-devel depending on OS/distribution) installed. The part of the package essential to linking is a symlink /usr/lib/libgd.so (usually pointing to /usr/lib/lib/libgd.so.2)

CUDA linking error in Ubuntu 12.04

I have been searching everywhere for a solution to my problem:
I cannot run a .cpp file using CUDA. I think this is a module error since I get the following error:
g++ -L/usr/local/cuda/lib64 -L~/NVIDIA_GPU_Computing_SDK/shared/lib/linux -L~/NVIDIA_GPU_Computing_SDK/C/common/lib/linux -L~/NVIDIA_GPU_Computing_SDK/C/lib -lcutil -lcudpp -lcuda -lcudart -lcurand -o my_file my_file.o
/usr/bin/ld: cannot find -lcutil
/usr/bin/ld: cannot find -lcudpp
My makefile looks like this:
EXECUTABLE := my_file
SDKPATH := ~/NVIDIA_GPU_Computing_SDK
CUDAPATH := /usr/local/cuda
LDFLAGS := -L$(CUDAPATH)/lib64 -L$(SDKPATH)/shared/lib/linux -L$(SDKPATH)/C/common/lib/linux -L$(SDKPATH)/C/lib -lcutil -lcudpp -lcuda -lcudart -lcurand
CXFLAGS := -I$(CUDAPATH)/include -I$(SDKPATH)/shared/inc -I$(SDKPATH)/C/common/inc
CXX := g++
NVCC := $(CUDAPATH)/bin/nvcc
$(EXECUTABLE): my_file.o
$(CXX) $(LDFLAGS) -o $(EXECUTABLE) my_file.o
my_file.o: my_file.cu
$(NVCC) $(CXFLAGS) -c my_file.cu
When I, instead try to run the file manually I get the following output:
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
my_file.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_00000e8f_00000000-1_my_file.cudafe1.cpp:(.text+0xf): undefined reference to `__cudaUnregisterFatBinary'
my_file.o: In function `__sti____cudaRegisterAll_59_tmpxft_00000e8f_00000000_4_my_file_cpp1_ii_71dc03a4()':
tmpxft_00000e8f_00000000-1_my_file.cudafe1.cpp:(.text+0x1f): undefined reference to `__cudaRegisterFatBinary'
collect2: ld returned 1 exit status
I'm a total noob when it comes to linux.
Can anyone please shed some light on this situation.
Regards
You have an ordering problem in the linking phase of your build. Because the libraries you specify are provided before the files that require them, they get discarded. If you change your makefile to something like:
LDFLAGS := -L$(CUDAPATH)/lib64 -L$(SDKPATH)/shared/lib/linux -L$(SDKPATH)/C/common/lib/linux
LIBS := -lcutil -lcudpp -lcuda -lcudart -lcurand
....
$(EXECUTABLE): my_file.o
$(CXX) $(LDFLAGS) -o $(EXECUTABLE) my_file.o $(LIBS)
you should find the problem goes away.