Mastery14

Creating your own and using C++ libraries
1) Create the files "mylibrary.h" and "mylibrary.cpp".
2) Only compile the library, and it shouldn’t have a "main()" function in it. This step will generate an object file called "myfile.o".
3) Create another file called something like "main.cpp". In main.cpp you need to "mylibrary.h".
4) Compile main.cpp and add the library from step 2 to link in (in this case "myfile.o"). If you don’t add this library, you’ll get a error message like "linker error – can’t find function definition", or something like that.

TC1017

CC BY 4.0 Mastery14 by ivanna lases is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.