0

When using .a files, do I have to distribute the .cpp files with it or just the .h files?

For example, I wrote a large amount of classes and compiled all the code into .o files. I then archived the .o files into .a files.

When I attempt to use the .a files with the .h files in other projects, it requires me to have the .cpp file sometimes.

For some of the headers, it doesn't ask me for the .cpp files but for stuff like sockets it gives undefined references to impl_shutdown unless I include the .cpp file.

This happens even though I link all necessary libs.

Why? What are .o/.a files really and why do I need to distribute the .cpp files with it? Libraries like Zlib and LibPng don't seem to have to distribute anything but the .h and the .a files.

4

2 回答 2

2

When using .a files, do I have to distribute the .cpp files with it or just the .h files?

Only the headers.

What are .o/.a files really

.o files are object code, .a are archives (collections of object files). They're compiled and assembled machine code, that need to be linked in order an executable file to be created.

and why do I need to distribute the .cpp files with it?

You don't.

于 2013-03-30T21:45:28.680 回答
1

Just the libraries and the headers will be fine.

Make sure that if your objects are over multiple libraries, there are no circular dependencies. If there are, you need to specify the libraries multiple times in order for the linker to pick them up.

于 2013-03-30T21:45:14.270 回答