I am trying to successful execute a make file that comes from a new crytpo-coin called Sia Coin. It can be found here Sia Coin GPU Miner. It's relatively new and so some stuff requires more manual installation. I was getting the following error on Ubuntu 16.04 when using the make file. CL/cl.h was missing, and I was able to install and it is located at /usr/include/nvidia-361/CL/cl.h. However, when I ran the make file I still get errors so I think I need to include this path someone in the Make file, the problem is I am not familiar with make files at all. Below is the Make file I need to edit to include the path for compilation:
ifeq ($(shell uname -s),Darwin)
CC ?= clang
LDLIBS += -lcurl -framework OpenCL
else
CC ?= gcc
LDLIBS += -lOpenCL -lcurl
endif
CFLAGS += -c -std=c11 -Wall -pedantic -O2
TARGET = sia-gpu-miner
SOURCES = sia-gpu-miner.c network.c
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
all: $(TARGET)
%.o: %.c
$(CC) $(CFLAGS) -o $# $<
$(TARGET): $(OBJECTS)
$(CC) -o $# $^ $(LDLIBS)
clean:
rm -f $(TARGET) $(OBJECTS)
.PHONY: all clean
Any help toward solving this problem is greatly appreciated.
Edit:
A new message I am getting now adding
CFLAGS += -c -std=c11 -Wall -pedantic -O2 -I /usr/include/nvidia-361
is now:
-lOpenCL -lcurl /usr/bin/ld: cannot find -lOpenCL collect2: error: ld returned 1 exit status
Two files did compile:
sia-gpu-miner.c
network.c
But I don't know enough to know why the -lOpenCL is not found. No ld directory exists in that directory location in the error if that helps.
Try changing
CFLAGS += -c -std=c11 -Wall -pedantic -O2
to
CFLAGS += -c -std=c11 -Wall -pedantic -O2 -I /usr/include/nvidia-361
Related
I'm new to Makefiles, so far I've only been doing little projects, but I just did my biggest project with 20 *.c files and put them all in a src file.
With my Makefile I wanted to create an obj file with all the corresponding *.o files and then make them all into an executable. I heard about Static Patterns and I tried to use it on my makefile but I'm probably making a very silly mistake as the output is not what I expected.
My Makefile:
CC=gcc
CFLAGS=-Wall -Wextra -Werror
MLX=mlx/libmlx_Darwin.a
LIBFT=libft/libft.a
I_LIBFT=-Ilibft -Llibft -lft
I_LIBMLX=-Imlx -Lmlx -lmlx
LIB=$(I_LIBFT) $(I_LIBMLX)
COMPATIBILITY=-lX11 -lXext
FRAMEWORK=-framework OpenGL -framework AppKit
HDR=/include/fdf.h
SRC_DIR=/src/
SRCS:=$(wildcard $(SRC_DIR)*.c)
OBJ_DIR=/obj/
OBJS=$(patsubst %.c, $(OBJ_DIR)%.o, $(SRCS))
all: $(LIBFT) app
$(LIBFT):
make -C libft
#echo "done libft"
$(OBJ_DIR):
mkdir $#
$(OBJS): $(OBJ_DIR)%.o: $(SRC_DIR)%.c $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $#
app: $(OBJS)
#echo "making app"
$(CC) $(CFLAGS) $(LIB) $(FRAMEWORK) $(OBJS) -o FdF
clean:
make -C libft $#
fclean: clean
make -C libft $#
re: fclean all
.PHONY: all clean fclean re so
My output:
making app
gcc -Wall -Wextra -Werror -Ilibft -Llibft -lft -Imlx -Lmlx -lmlx -framework OpenGL -framework AppKit -o FdF
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [app] Error 1
when I expected something like:
gcc -Wall -Wextra -Werror -c file.c -o file.o
gcc -Wall -Wextra -Werror -c file2.c -o file2.o
gcc -Wall -Wextra -Werror -c file3.c -o file3.o
...
gcc -Wall -Wextra -Werror -Ilibft -Llibft -lft -Imlx -Lmlx -lmlx -framework OpenGL -framework AppKit file.o file2.o ... file19.o -o FdF
What am I doing wrong?
I'm pretty sure these are wrong:
HDR=/include/fdf.h
SRC_DIR=/src/
OBJ_DIR=/obj/
Are your source and header files REALLY in a subdirectory of the root of your partition? If you run ls /src/ does it actually show any files?
I suspect that there is nothing there, which means that SRCS is empty because the wildcard expands to no matches, which means OBJS is empty since it's substituting into nothing, which means there are no prerequisites to the app target.
I'm trying to compile a C program on Windows for use on a linux dev board.
When I try to compile using a makefile I get this output:
$ make
arm-linux-gnueabihf-gcc -g -Wall main.c -o filetest
process_begin: CreateProcess(NULL, arm-linux-gnueabihf-gcc -g -Wall main.c -o filetest, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [filetest] Error 2
This happens whether or not a blank file called filetest is present or not in the same directory. If it is present, I can run make clean and it will remove the file.
Here is the makefile I'm using:
#
TARGET = filetest
ALT_DEVICE_FAMILY ?= soc_cv_av
SOCEDS_ROOT ?= $(SOCEDS_DEST_ROOT)
HWLIBS_ROOT = $(SOCEDS_ROOT)/ip/altera/hps/altera_hps/hwlib
CROSS_COMPILE = arm-linux-gnueabihf-
CFLAGS = -g -Wall -D$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/$(ALT_DEVICE_FAMILY) -I$(HWLIBS_ROOT)/include/
LDFLAGS = -g -Wall
CC = $(CROSS_COMPILE)gcc
ARCH= arm
build: $(TARGET)
#
$(TARGET):main.c
$(CC) $(LDFLAGS) $^ -o $#
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $#
.PHONY: clean
clean:
rm -f $(TARGET) *.a *.o *~
I used tabs in my actual makefile instead of spaces for the code block above ^^
Also, I'm working within Intel's FPGA SoC EDS for a Cyclone V board.
I'm learning how to use C and Make, but Make is making me tear my hair out. When I run make with all targets I've created it fails, running gcc with no parameters, except one of them randomly works just fine. Here is what happens when I try to build with most of the targets:
$ make strvector.o
gcc
gcc: fatal error: no input files
compilation terminated.
make: *** [vector.o] Error 4
and when I run the one that works:
$ make word.o
gcc -Wall -g -ansi -pedantic -c -o word.o word.c
Here is my makefile:
CC = gcc
CFLAGS = -Wall -g -ansi -pedantic -c -o $# $^
LD = gcc
LDFLAGS =
fw: fw.o vector.o hashtable.o strvector.o
$(LD) $(LDFLAGS) -o fw vector.o hashtable.o strvector.o word.o
fw.o: fw.c vector.o hashtable.o strvector.o word.o
$(CC) $(CFALGS)
vector.o: vector.c word.o
$(CC) $(CFALGS)
hashtable.o: hashtable.c vector.o word.o
$(CC) $(CFLAGS)
word.o: word.c
$(CC) $(CFLAGS)
strvector.o: strvector.c
$(CC) $(CFALGS)
I cannot for the life of me figure out why word.o builds fine but not anything else. If anyone could help that would be much appreciated.
--Edit-- I made a typo. Writing CFALGS instead of CFLAGS. not sure how I missed that one. Thanks guys!
You left out the filenames in the compilation commands.
strvector.o: strvector.c
$(CC) -c $(CFLAGS) -o $# $<
$# gets replaced with the current target, $< is replaced with the current dependency.
I am trying to compile a C language library as a shared object on my new install of Fedora 22. The project compiled fine on my old install of Fedora 20. But now, when I run my makefile:
CC=gcc
vpath %.c src
vpath %.h inc
CFLAGS = -fPIC
INCLUDE = -Iinc -I/usr/include -I/usr/local/include
LIBPATH = -L/usr/lib -L/lib64
LIBS = -lportaudio -lm -lpthread -ldl
OBJ_PATH = ./objs
SRCS = my_code1.c my_code2.c # etc.
OBJS = $(SRCS:.c=.o)
.PHONY: libmylib.so
all: libmylib.so
debug: $(CFLAGS) += -DDEBUG -O0 -g3 -DPD
debug: all
release: $(CFLAGS) += -DTESTING -O2 -DPD -funroll-loops -fomit-frame-pointer
release: all
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE) $(LIBPATH) $(LIBS) -c -o $# $^
libmylib.so: $(OBJS)
$(CC) -shared -Wl,-soname,libmylib.so \
-Wl,--no-undefined $(OBJS) -lc -lportaudio -ldl -lm -lpthread
mv libmylib.so ./bin
mv *.o $(OBJ_PATH)
clean:
rm $(OBJ_PATH)/*.o
rm bin/libmylib.so
I get very many undefined reference errors:
my_code1.o: In function `func_in_my_code1':
my_code1.c:(.text+0x1b8): undefined reference to `func_from_my_code2'
my_code2.o: In function `func_in_my_code2':
my_code2.c:(.text+0x310): undefined reference to `func_from_my_func1'
The functions in question are most certainly defined in the code. Presumably these are compiled into .o files in the compile stage.
The exact same build environment worked on my previous fedora installation. I am at a loss as to why I should get these errors.
Also, if I compile without the -Wl,--no-undefined flag, it compiles fine, but when I try to load the library from another application, it tosses the same set of undefined errors.
This may have nothing to do with the new version of Fedora. It is possible that there are some environment variables or something that didn't make through to my new install, but I have no idea what they could be.
Apparently I now need to insert the extern keyword into these functions. The code compiled and ran perfectly well before... I would like to reiterate, for posterity's sake, that I did post the entire makefile in my question.
I have a make file that I am trying to a make more flexible. So, if I am building an executable, there is primary.c and primary.h. Along with that, there are two other pairs of files that I need to build into the executable: helper_funcs.c / helper_funcs.h and fork.c / fork.h.
CC = gcc
CFLAGS = -c -g -Wall -Wextra
SOURCES = fork.c helper_funcs.c
DEPS = primary.h fork.h helper_funcs.h
OBJECTS = $(SOURCES:.c=.o)
EXECUTABLE = primary
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(OBJECTS) -o $#
.c.o: $(DEPS)
$(CC) $(CFLAGS) $< -o $#
clean:
rm -f *.o
rm -f $(EXECUTABLE)
My goal is to write this make file such that no matter how many additional source files I may have, all I have to do is add them to the SOURCES list and the Makefile will handle the compilation and linking.
When I go to compile this, I get the following:
rm -f *.o
rm -f primary
gcc -c -o fork.o fork.c -c -g -Wall -Wextra
gcc -c -o helper_funcs.o helper_funcs.c -c -g -Wall -Wextra
gcc -c -o primary.o primary.c -c -g -Wall -Wextra
primary.c: In function ‘build_state’:
primary.c:114: warning: implicit declaration of function ‘make_passive’
primary.c:120: warning: implicit declaration of function ‘make_active’
primary.c:127: warning: implicit declaration of function ‘string_builder’
primary.c: In function ‘main’:
primary.c:172: warning: implicit declaration of function ‘read_file’
gcc fork.o helper_funcs.o routed_LS.o -o routed_LS
The functions that it doesn't see are those included in the helper_funcs.c file. It seems to be picking up the functions in fork.c, but I can't understand where the difference lies.
Can anyone help me figure out how to clear these errors? Thanks!