I'm trying to compile a sample from a project, the following code is the makefile:
CC = gcc
MACHINE= $(shell uname -s)
#declaration des options du compilateur
#PG_FLAGS = -DOPENGL_1_5
ifeq ($(MACHINE), Darwin)
GL_LDFLAGS = -framework OpenGL -framework GLUT -framework Cocoa -framework
Carbon
else
GL_LDFLAGS = -lopengl32 -lglu32 -lglut
endif
CFLAGS = -Wall
LDFLAGS = -lm $(GL_LDFLAGS)
PROGNAME = palette
HEADERS = image.h
SOURCES = Main.c ppm.c fonctions.c
I tried: "mingw32-make" and i got:
process_begin: CreateProcess(NULL, uname -s, ...) failed.
gcc Main.o ppm.o fonctions.o -lm -lopengl32 -lglu32 -lglut -o palette
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-
w64-mingw32/bin/ld.exe: cannot find -lglut
collect2.exe: error: ld returned 1 exit status
Makefile:25: recipe for target 'palette' failed
mingw32-make: *** [palette] Error
but i have the glut library installed
and i am using windows 10
i have found the solution for this problem
GLUT library have been abandoned with the most recent version 3.7. Also, GLUT's license is incompatible with some software distributions .... so i used freeGLUT insted of it and it works
and there is the link to download it :
https://www.transmissionzero.co.uk/computing/using-glut-with-mingw/
goodluck evryone :)
Related
Im using windows 10 with wsl ubuntu 18.04 Im trying to run the code from here :
https://www.ccs.neu.edu/home/skotthe/classes/cs5600/fall/2015/labs/intro-check-lab-code.tgz
I installed gcc, makefile, and check in the ubuntu terminal. But when I di $ make it says:
gcc money.o check_money.o -lcheck -lm -lpthread -lrt -lgcov -coverage -o check_money_tests
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcheck.a(check_log.o): In function `subunit_lfun':
(.text+0x5f4): undefined reference to `subunit_test_start'
(.text+0x6bf): undefined reference to `subunit_test_fail'
(.text+0x6d4): undefined reference to `subunit_test_pass'
(.text+0x6ef): undefined reference to `subunit_test_error'
collect2: error: ld returned 1 exit status
Makefile:23: recipe for target 'check_money_tests' failed
make: *** [check_money_tests] Error 1
so I open the check_money.c it says that check.h cannot be found. What did I miss here?
Simple version: you should also link with -lsubunit flag, i.e.:
TST_LIBS = -lcheck -lm -lpthread -lrt -lsubunit
Better yet, all the flags should be taken from check's package configuration, as the requirements depend on how the check library was built (and that's what pkg-config has been invented for). So instead of hardcoding your options, you could improve your Makefile like this:
CFLAGS = -c -Wall $(shell pkg-config --cflags check)
TST_LIBS = $(shell pkg-config --libs check)
Result:
$ make
gcc -c -Wall -pthread -fprofile-arcs -ftest-coverage src/*.c
gcc -c -Wall -pthread -fprofile-arcs -ftest-coverage tests/*.c
gcc money.o check_money.o -lcheck_pic -pthread -lrt -lm -lsubunit -lgcov -coverage -o check_money_tests
...
I'm trying to compile my patched dwm on Debian.
This is my config.mk file, it's mostly the one from apt source dwm but the patches added some extra libraries, and I had to add the two -Ifreetype2 links myself:
# dwm version
VERSION = 6.1
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
# freetype
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} -I/usr/include/freetype2 -I/usr/include/libpng16
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lX11-xcb -lxcb -lxcb-res
# flags
CPPFLAGS += -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS += -std=c99 -pedantic -Wall -Wno-deprecated-declarations ${INCS} ${CPPFLAGS}
LDFLAGS += -s ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
# compiler and linker
CC = cc
This is the error I get when running make clean install
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
/usr/bin/ld: dwm.o: undefined reference to symbol 'XMapSubwindows'
/usr/bin/ld: //lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: dwm] Error 1
But I have no idea how to fix this. Do I need a library installed? do I need to add somthing to the libs variable? please help!
I have tried looking at this, but I have no idea what a "DSO" is, nor how to fix the linkage.
Not sure if it's the only problem but your link line...
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
appears to have a -L option with no parameter. Or, perhaps more correctly, it will assume that its parameter is -lX11. I'm assuming this is because the variable X11LIB is unspecified in your makefile. Not sure exactly how X11LIB is supposed to be specified with the makefile you're using but you could try setting it explicitly...
X11LIB := /usr/lib64 # Assumes the path to libX11.so is /usr/lib64/libX11.so
-L -lX11
This means "add a directory named -lX11 to the library search path". This is unlikely to have any effect as such directory probably does nit exist.
Remove -L or add a non-empty directory argument after it.
I'm on a linux system (arch linux specifically) and I'm trying to compile the introduction project from the official glfw page but I cannot seem to get gcc to compile it. If anyone doesn't know what I'm talking about it's this.
Also this is how I'm trying to compile it:
gcc -Iinclude test.c -o test -lglfw3 -lm -lGL -lGLU
and it gives me the following errors:
/usr/bin/ld: cannot find -lglfw3
collect2: error: ld returned 1 exit status
I completely forgot about this question until I got a notification for it. For me the solution was to not use -lglfw3 but rather use -lglfw
If you've installed pkg-config, and glfw3.pc is in the search path, try:
gcc -Iinclude test.c -o test `pkg-config --libs glfw3` -lm -lGL -lGLU
If you only have the static build, use: pkg-config --static --libs glfw3, which will add the dependencies that libglfw3.a requires.
Find libglfw3.a or libglfw3.so on your system
Mention that path to gcc using -L
gcc -Iinclude test.c -o test -L/dir/where/glfw3/resides -lglfw3 -lm -lGL -lGLU
I starting an project using OpenGL in Linux (Ubuntu 13.10) and i have an basic source code from my professor that compiles in his computer.
When i treid to compile it here, (i have the open gl libraries working in other projects), i got the following error in terminal:
gcc -o quadtree quadtree.o glm.o winGL.o -lglut -lGL -lGLU
/usr/bin/ld: glm.o: referência indefinida ao símbolo 'acos##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: ** [quadtree] Erro 1
("referência indefinida ao simbolo" means "undefined reference to symbol")
I searched in internet and got hints that this could be an error in the makefile, but i dont know what is wrong. There is my makefile:
.c.o: $*.h
gcc -c $*.c
.cpp.o: $*.h
g++ -c $*.cpp
all: quadtree
quadtree: quadtree.o glm.o winGL.o
gcc -o $# $^ -lglut -lGL -lGLU
clean:
rm *.o *.*~ *~ quadtree
Is there any command missing?
You forgot to link with -lm, see man acos
I am trying to compile a C program for my CS class. I have Command Line tools installed on my Mac, so I probably have OpenGL. The program description was made for Ubuntu and it says for me to compile using:
gcc -Wall -ansi -pedantic -O2 main.o graphic.o imagem.o io.o -o ep2 -lGL -lGLU -lglut
I ran that and it said:
ld: library not found for -lGL
What flags should I use? What do I do?
In MacOS X you're not using libraries to include system level APIs, but Frameworks. The proper command line to compile this program would be
gcc -Wall -ansi -pedantic -O2 \
main.o graphic.o imagem.o io.o \
-o ep2 \
-framework OpenGL -lGLU -lglut
Note that GLU is probably part of the OpenGL framework as well. And it may be required to install GLUT first.
I found you have to use
-framework OpenGL -framework GLUT
Reference