Author | Message |
---|---|
se1k1h1mawar1
Posts: 121
|
Posted 13:08 Jan 15, 2015 |
After copying all the source files (i.e. util.c, utility.h, Sample1.cpp etc) to my mars.calstatela.edu account via ssh, I executed the command to create an object file (util.o) off of util.c. It seemed to have compiled the util.c file fine, and the object file was created successfuly since I did not get any error message at this point.
By reading the error message, I understood that the OS looks for the functions and variables defined in util.c such as process_fork, process_join in ccJNC5bS.o in "tmp" directory inside "var" instead of the actual location in which I have my object file (util.o). Am I correct in interpretating this error message? Could anybody please suggest how I can link the location of which the OS will look for these functions and variables ( clearly invisible to it currently)? I hope my understanding of the materials is not too off. Last edited by se1k1h1mawar1 at
13:10 Jan 15, 2015.
|
gjmiles
Posts: 17
|
Posted 19:07 Jan 15, 2015 |
What command arguments did you use with g++? The text example was something like: g++ -o foo foo.cpp /path/to/util.o |
se1k1h1mawar1
Posts: 121
|
Posted 19:23 Jan 15, 2015 |
The command I used to compile util.c and to create the object file:
The commands I tried to compile sample1.cpp:
In case it clarifies my question better, I will list the outputs I got in response to the above commands. ---- Commad -----> gcc -c util.c -o util.o ---- Commad -----> g++ sample1.cpp sample1 ---- Commad -----> g++ sample1.cpp -o sample1 ---- Commad -----> ls ---- Commad -----> g++ sample1.cpp
Thank you, |
gjmiles
Posts: 17
|
Posted 20:24 Jan 15, 2015 |
You have to include the util.o library in g++ arguments when you compile a program that is linking to it. If util.o is in the same directory as your source code file then you do not need to specify a path. i.e.: g++ -o sample sample1.cpp util.o |
se1k1h1mawar1
Posts: 121
|
Posted 20:27 Jan 15, 2015 |
Oh my goodness, I cannot believe I missed that...
Last edited by se1k1h1mawar1 at
20:29 Jan 15, 2015.
|
kevinmowers@yahoo.com
Posts: 49
|
Posted 14:58 Jan 20, 2015 |
I'm getting these kind of errors when I try to compile util.c util.c:1: error: syntax error before '<' token what am I doing wrong? |