Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: lissalissa on August 07, 2022, 07:30:17 pm

Title: Host application to "run" a library
Post by: lissalissa on August 07, 2022, 07:30:17 pm
Hello, friends,
I am authoring a dynamic library on Fedora 36 using codeblocks.  This is the first time I've written my own library, and what I would like to have happen is to click "build and run", have the library compiled, and then have some code execute to run some unit tests.  When I click build and run the error I get is "You must select a host application to 'run' a library...".  I can find no guidance on how to specify a host application.

Is there any way to extract the behavior for which I'm looking, or similar behavior?
Thanks!
Title: Re: Host application to "run" a library
Post by: Miguel Gimenez on August 07, 2022, 08:38:58 pm
Libraries are not executable, you need an application using them. In your case the "Host application" should be that containing the tests.
Title: Re: Host application to "run" a library
Post by: lissalissa on August 07, 2022, 10:36:46 pm
So if I'm understanding correctly, I need to create a separate project that builds an executable and links to my library project?
Title: Re: Host application to "run" a library
Post by: Miguel Gimenez on August 08, 2022, 11:15:37 am
Not necessarily a separate project, it may be a new target in your current project.

That project (or target) will contain the "code execute to run some unit tests".
Title: Re: Host application to "run" a library
Post by: SpaceCadet on August 11, 2022, 06:27:38 pm
you may not necessarily need a second project, but it makes sense to create one.  i call these apps 'harness' to exercise one or more libraries.  you will be able to test 2nd or 3rd libraries in the future and you will be able to explore the uses of libraries.  make an app call it myApp and link to your library.a file or library.so.
Title: Re: Host application to "run" a library
Post by: lissalissa on August 14, 2022, 07:47:28 pm
Okie dokie! Thank you so much for the help!