Beginner
Beginner

Reputation: 2886

compile a .c file with dependencies

I 'inherited' a bunch of files from my professor and she asked me to see if I can make sense of the whole project. Its a mish-mash of a bunch of files ( python, c, java) that are to be run one after the other on a particular data set. From what I have seen the code is very poorly written and the README is a joke.

The first step involves running a python script with the dataset and 2 more arguments. The last line of this file is

os.system("./blar " + str(raw_datafile) + " " + str(combos) + " " + str(mine1) + " " + str(mine2))

which translates to -

./blar RareDiseaseDataSet.xlsx 57 1 84

I know os.system executes a command in a subshell. however when the above command is executed the result is ./blar: No such file or directory. The folder has a file named blar.c . My c knowledge is very basic , in order to generate an executable i tried make blar.c , gcc blar.c -o blar but to no avail. How do I get this to run?

EDIT Tried these commands -

$ make blar.c
make: Nothing to be done for `blar.c'.

$ gcc blar.c -o blar
/tmp/ccblMR3s.o: In function `nonsingles':
blar.c:(.text+0x359): undefined reference to `checknull'
blar.c:(.text+0x3e3): undefined reference to `checknull'
blar.c:(.text+0x759): undefined reference to `next_comb'
/tmp/ccblMR3s.o: In function `main':
blar.c:(.text+0xa20): undefined reference to `readfile'
blar.c:(.text+0xa2d): undefined reference to `checknull'
blar.c:(.text+0xb44): undefined reference to `destroy_file_array'
collect2: ld returned 1 exit status

TL;DR How to create an executable from a .c file.

P.S. - Running this on a school server, which is prehistoric and uses python 2.4.x

Upvotes: 2

Views: 648

Answers (1)

alexis
alexis

Reputation: 50180

You were on the right track with gcc blar.c -o blar. Presumably it failed, so you have to figure out why (examine the error message) and fix that. If there's a Makefile in the directory, it'll contain recipes for building everything (if you're lucky).

PS. Looks like your blar program has to be able to read an Excel spreadsheet; almost certainly it relies on additional source files or libraries, so you'll need to compile and/or link additional files in the command that builds blar. I really hope you've got a Makefile.

Upvotes: 1

Related Questions