Question

I'm using code::blocks on a linux system with the gcc compiler, and I want to be able to use the shared library template to make a shared library with classes, then make another project that accesses that shared library(at compile time, not dynamically) and classes. I'm sure that code::blocks has simple way of doing this without making custom makefiles and manually setting link options, but I don't know how. How do I do this.

Thanks

ps(please stick to the question).

Example of what I want to do

Shared Library

sl.h

class clsClass
{
    public:
    static bool bolReturnTrue(char * chWhatever);
};

sl.cpp

bool clsClass::bolReturnTrue(char * chWhatever)
{
    return true;
}

Program Accessing Shared Library

main.cpp

int main(int argc, char * argv[])
{
    bool Face = clsClass::bolReturnTrue(argv[0]);
    if(Face)
    {
        printf("True.\n");
    }
    else
    {
        printf("False.\n");
    }
    return 0;
}
Was it helpful?

Solution

You can have more then one project in your workspace and set project dependencies, there are no custom makefiles needed.

The basic steps with Code::Blocks are the following:

  • make sure your shared library project generates an import library (project properties->build targets)
  • make the shared lib project a dependency of the project in question (project settings->project dependencies)
  • link to the import library
  • include your shared libraries headers in the relevant source files
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top