Question:
How would I make my own C++ library files?
2011-04-04 04:33:38 UTC
I am not just talking about header files I want to be able to create a ".lib" file for C++. What would I be able to create with a .lib file?
Three answers:
M3taSpl0itâ„¢
2011-04-04 05:08:39 UTC
Here is the article from MSDN to create a static library :



http://msdn.microsoft.com/en-us/library/ms235627.aspx
koppe74
2011-04-04 04:56:52 UTC
Which OS are you using? What c++-compiler are you using?



Do you intend to make a static library (.lib, .a) or a dynamic link library/shared library (.dll, .so)?



***Under Unix/Linux:

-Create a static library:

1) g++ -Wall -c func1.cpp func2.cpp func3.cpp

Results in three object-files func1.o, func2.o and func3.o

2) ar -cvq mylib.a func1.o func2.o func3.o

Creates the static library mylib.a

-Create a shared library:

1) g++ -Wall -fPIC -c func1.cpp func2.cpp func3.cpp

Creates three object-files, that can be used for dynamic-linking

2) g++ -shared -Wl,-soname,mylib.so.1 -o mylib.so.1.0 func1.o func2.o func3.o

Creates a shared library called mylib.so.1.0

3) Move the library to suitable location

4) Make to symbolic links:

ln -s mylib.so.1.0 mylib.so.1

ln -s mylib.so.1 mylib.so

5)Update the linker cache
proto
2016-11-06 09:25:26 UTC
comprise you employ for technique libraries, libraries which could be set up via capacity of alternative applications to be utilized in all varieties of programs. you employ #comprise "document.H" for header data you're making your self, on the full you employ them in case you opt to declare features, systems, typedefs, definitions and involves in a separate, international document then use them on your c data. case in point i'm going to have in document.H: #contain struct something int x; int y; ; int dosomething(void); int top-rated(int, char *[]); then in document.C i'd have #comprise "document.H" int standard(int argc, char *argv[]) /* utility */ return 0; and that i'd have dosomething() in yet yet another document as a thank you to additionally comprise document.H.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...