Results 1 to 2 of 2
Hi All,
I am trying to compile a C++ source file into a static library using make with root priviliges (i.e., using "sudo").
However, I "sometimes" get the following compilation ...
- 01-27-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 43
GNU make, libboost-filesystem1.40-dev and Linux file permissions
Hi All,
I am trying to compile a C++ source file into a static library using make with root priviliges (i.e., using "sudo").
However, I "sometimes" get the following compilation error:
I checked /home/project/ether/src folder to see if packet-ethernet.o in fact does not exist, and saw that it is actually located there, but its owner is "root", which is different from the current user. If I change the owner of packet_ethernet.o from root to the current user using "chown" command and execute make again with sudo, everything seems to be fine.Code:g++ -Wall -g -fPIC -W -c /home/project/ether/src/packet-ethernet.cc ar -cvq libether.a /home/project/ether/src/packet-ethernet.o ar: /home/project/ether/src/packet-ethernet.o: No such file or directory make: *** [libether.a] Error 1
It may be a coincidence that I recently migrated to 64-bit platform from 32-bit, and then installed libboost-filesystem1.40-dev. After that, I began to experience such errors.
I have "never" come across such a compilation error before. Even though I completely removed libboost-filesystem1.40-dev afterwards to see if it causes the problem, nothing changed.
After migrating to 64-bit and installing libboost-filesystem1.40-dev, my application exhibited another "weird" behaviour such that it produced "hidden" files using mkdir() system call, which were previously created as regular ones on the filesystem.
Can compiler options that I use cause such problems ?
OR
Is it possible that libboost-filesystem1.40-dev overwrote some system libraries so that I am getting such errors ?
Thanks.
- 01-30-2010 #2
The object file will be created in the current directory, so your example will fail if the current direction is not /home/project/ether/src/.
Alternately you can specify the output with the -o compiler switch, or just not specify the directory of the .o file to ar.
Also, it's always advisable to to as little with elevated privileges as possible, so it would be better to compile the whole thing as a non-root user and then install it as root.


Reply With Quote