3 Replies - 1120 Views - Last Post: 11 December 2012 - 10:12 AM Rate Topic: -----

#1 xZachtmx  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 125
  • Joined: 14-June 09

Trying to compile C code where I know the location of all includes.

Posted 10 December 2012 - 11:36 AM

Hi guys, I have never really done anything in C before, but I was using a certain dialect of LISP that compiles into C. The problem is the tool to make the makefile and organize everything does not work at all. So I have 3 C files that have all the compiled code that I have written, along with many of the library source files and header files that I should include. The problem is there are alot of files and I dont really know which ones exactly are needed (because I wrote it in this LISP code). When I use the interpreter on the C code that comes with the language it works fine so I know it runs ok but It would take me forever to figure out how the entire interpreter works. So far I have this in my Makefile:
CC = gcc -std=gnu99
LUSHFLAGS = -DNOLISP    -DNO_DEBUG -Wall -O3 -march=nocona -mmmx -msse -pthread
X_CFLAGS =  -I/usr/include/freetype2
X_LIBS =  -lXft -lSM -lICE -lX11
LIBS = -lm -lc
DEFS = -DHAVE_CONFIG_H
MAIN = -DC_propogate=main
OBJS = lush_runtime.o check_func.o dsource_mnist2.o lenet5_fprop.o test_fprop.o
test: ${OBJS}
	$(CC) -o test ${OBJS} ${LIBS}
.c.o:
	${CC} ${MAIN} ${DEFS} ${X_CFLAGS} ${LUSHFLAGS} -c $<



And I have those 5 c source files in the folder. So I get a bunch of expected "undefined reference to" errors. Is there a way to just set a search path like I do for C++ code to find all of the code I need, I know where everything is including the headers I just dont know how to put it all together. Maybe this is confusing to others too but if anyone can give any suggestions it would be greatly appreciated. I just need this to work on

Is This A Good Question/Topic? 0
  • +

Replies To: Trying to compile C code where I know the location of all includes.

#2 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 651
  • View blog
  • Posts: 2,224
  • Joined: 31-December 10

Re: Trying to compile C code where I know the location of all includes.

Posted 10 December 2012 - 12:27 PM

What's the name of the C file that contains the main() function?
Was This Post Helpful? 0
  • +
  • -

#3 xZachtmx  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 125
  • Joined: 14-June 09

Re: Trying to compile C code where I know the location of all includes.

Posted 10 December 2012 - 02:55 PM

View Postvividexstance, on 10 December 2012 - 12:27 PM, said:

What's the name of the C file that contains the main() function?


It is test_fprop.c
Was This Post Helpful? 0
  • +
  • -

#4 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 651
  • View blog
  • Posts: 2,224
  • Joined: 31-December 10

Re: Trying to compile C code where I know the location of all includes.

Posted 11 December 2012 - 10:12 AM

Here is how a typical Makefile that I use for small projects(with some of your Makefile in it):
CC = gcc
LUSHFLAGS = -DNOLISP    -DNO_DEBUG -Wall -O3 -march=nocona -mmmx -msse -pthread
X_CFLAGS =  -I/usr/include/freetype2
X_LIBS =  -lXft -lSM -lICE -lX11
LIBS = -lm -lc
DEFS = -DHAVE_CONFIG_H -DC_propogate=main
OBJ = lush_runtime.o check_func.o dsource_mnist2.o lenet5_fprop.o
NAME= fprop_test
SRC = fprop_test.c

$(NAME) : $(SRC) $(OBJ)
	$(CC) ${DEFS} ${X_CFLAGS} ${LUSHFLAGS} ${X_LIBS} ${LIBS} $(OBJ) $< -o $@

%.o : %.c
	$(CC) ${DEFS} ${X_CFLAGS} ${LUSHFLAGS} -c $<

.PHONY : clean
clean :
	rm -rf $(OBJ) $(NAME)


Let us know if this works

This post has been edited by vividexstance: 11 December 2012 - 10:13 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1