User forums > Using Code::Blocks

Host application to "run" a library

(1/2) > >>

lissalissa:
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!

Miguel Gimenez:
Libraries are not executable, you need an application using them. In your case the "Host application" should be that containing the tests.

lissalissa:
So if I'm understanding correctly, I need to create a separate project that builds an executable and links to my library project?

Miguel Gimenez:
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".

SpaceCadet:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version