vendredi 22 décembre 2017

How to call Ctor from shared library?

First of all, I created a shared library of stereo.cc:

#include <iostream>
class Stereo {
  public:
    Stereo() { std::cout << " Ctor called " << std::endl; }
    ~Stereo() { }
};

Shell command: g++ -shared -fPIC stereo.cc -o libstereo.so

Then, I created a main.cc and want to compile it together with linked shared library (libstereo.so). Shell command: g++ main.cc -L. -lstereo

#include<iostream>
int main ()
{
  std::cout << "start main" << std::endl;
  Stereo a; // error: ‘Stereo’ was not declared in this scope
  return 0;
}

Error arises: error: ‘Stereo’ was not declared in this scope

What I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire