I have to compile a file .po to .mo with msgfmt, so I installed gettext (newest version) and do chmod 777 to my entire folder.
When I compile the file:
msgfmt /home/myuser/file.po -o /home/myuser/file.mo
there are no errors, no life signal, nothing.
How can I solve it?
You have to change the order of your command:
msgfmt /home/myuser/file.po -o /home/myuser/file.mo
to:
msgfmt -o /home/myuser/file.mo /home/myuser/file.po
The usage of msgfmt can you get with:
msgfmt --help
Related
Please use following shell commands to reproduce the problem:
# create subdirectory
mkdir subdir
# create source files with dummy functions
echo 'void func1(){}' > file1.c
echo 'void func2(){}' > ./subdir/file2.c
# compiling sources into object files
gcc -c file1.c -o file1.o
gcc -c ./subdir/file2.c -o ./subdir/file2.o
# creating "thin archive" file from object files
ar crT out.a file1.o ./subdir/file2.o
# running objcopy, which leads to an error
objcopy out.a out_copy.a
As a result, following error occurs:
objcopy:st0AENRL/subdir/file2.o: No such file or directory
P.S. Problem with objcopy occurs when "thin" archive is composed of object files from subdirectories.
Does anybody know if such objcopy's behavior is ok?
This is really a bug.
It was reported here.
Support of thin archives was temporary disabled.
Make a rule called all to compile and link in once file called "dinam" all files .c.
I have tried:
All:
gcc -c *.c
I need to kink all .o in one file.
This will suffice:
dinam:
gcc -c *.c
gcc *.o -o dinam
You can write more sophisticated makefiles when you are ready.
I'm writing two C programs. One of them uses library libnsd.so. I compile two C programs using makefile which looks like this:
CC=gcc
CFLAGS= -Wall -g -O -fPIC
RM= rm
HLAV=main
HLAVO=main.o
all:lib $(HLAV)
cc c2.c -o c2
main: $(HLAVO)
$(CC) -L. -o $(HLAV) $(HLAVO) -lnsd
lib: libnsd.so
libnsd.so: nsd.o nd.o
$(CC) -shared $< -o $#
nsd.o: nsd.c nsd.h nd.h
nd.o: nd.c nsd.h nd.h
clean:
$(RM) -rf *.o *.so main
When I try to run an aplication I get an error:
error while loading shared libraries: libnsd.so: cannot open shared
object file: No such file or directory
Anyone knows how to solve it?
The error msg means your program can't find the dynamic library libnsd.so.
You need to find the library path from your system.
If the lib is not on the regular path, I suggest put it on the regular path.
whereis libnsd.so
mv your_dir/libnsd.so /usr/local/lib
Note: If the library is does not exist on your system, you should install it first.
Then, use ldconfig to write the path in the config file:
sudo echo "/usr/local/lib" >> /etc/ld.so.conf
sudo ldconfig
Or if you don't have root priviledge in your workstation, you can simply change user environment path:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Is there a way to compile all .c files in a given folder by using the command line with GCC compiler ?
I've seen this page for Linux : http://www.commandlinefu.com/commands/view/3230/compile-all-c-files-in-a-directory but couldn't find any equivalent for CMD.
I guess gcc itself doesn't have such a parameter.
But you can try the regular wildcard argument of gcc *.c -o Output where the * (wildcard) is to read as "any".
You can compile your files with following command:
gcc -c -Wall file1.c file2.c file3.c
Here. -Wall will give you all the warnings and errors.
Do not forget to browse to the same directory where these files reside.
I am trying to compile a library file using other library files. I am using the following line in my makefile to create gameobject.o:
lib/gameobject.o: src/gameobject.cpp src/vector.hpp lib/objectevent.o lib/sprite.o
g++ $^ -c -o $# $(SFML_FLAGS)
All the dependencies comile correctly, but I get the following error when it tries to compile gameobject.o:
g++: fatal error: cannot specify -o with -c, -S or -E with multiple files
I'm still a bit new to using make/separating compilation, so I'm not quite sure what I should do. Do I just have to compile it without setting an output? Do I have to compile gameobject.o without using any of my other .o files? If that's true, wouldn't compile times get pretty big for large objects if you can't compile libraries with other libraries? Or am I just reading this error completely wrong?
You're not building a library file here. A .o file is an object file. Typically there is one object file per source file. When you use the compiler's -c option, it takes a single source file and compiles it into a single object file. You cannot add other object files into an existing object file, so adding both .o and .cpp files into the same compiler line with -c is not going to work.
If you want to create a library, that would be something like libfoo.a (the "a" here stands for "archive"). If you want to create an executable you can do that as well.
You need to be more clear about exactly what result you want before we can describe how to get it.
I had the same problem after I combined some projects of a solution to a single one. I find out there was tow .cpp files with same names and after I did rename one of them It solved.
You can create only one object .o file from one source file.
If you are using makefile to build the project. Make sure you are doing $< instead of $^
# Correct one
%.o: %.cpp
$(CPP) $(CFLAGS) -c -o $# $<
# InCorrect one
%.o: %.cpp
$(CPP) $(CFLAGS) -c -o $# $^