Author Topic: Host application to "run" a library  (Read 2948 times)

Offline lissalissa

  • Single posting newcomer
  • *
  • Posts: 8
Host application to "run" a library
« 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!

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Host application to "run" a library
« Reply #1 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.

Offline lissalissa

  • Single posting newcomer
  • *
  • Posts: 8
Re: Host application to "run" a library
« Reply #2 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?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: Host application to "run" a library
« Reply #3 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".

Offline SpaceCadet

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: Host application to "run" a library
« Reply #4 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.

Offline lissalissa

  • Single posting newcomer
  • *
  • Posts: 8
Re: Host application to "run" a library
« Reply #5 on: August 14, 2022, 07:47:28 pm »
Okie dokie! Thank you so much for the help!