Skip to content

Instantly share code, notes, and snippets.

@daviddoria
Created March 3, 2016 15:35
Show Gist options
  • Save daviddoria/0debb957378d22ee4690 to your computer and use it in GitHub Desktop.
Save daviddoria/0debb957378d22ee4690 to your computer and use it in GitHub Desktop.
#include "AbstractPoint.h"
//BOOST_CLASS_EXPORT_IMPLEMENT(AbstractPoint)
#ifndef ABSTRACT_POINT_H
#define ABSTRACT_POINT_H
class AbstractPoint
{
public:
virtual ~AbstractPoint(){}
virtual void DoSomething() = 0;
};
//BOOST_SERIALIZATION_ASSUME_ABSTRACT(AbstractPoint)
//BOOST_CLASS_EXPORT_KEY(AbstractPoint)
#endif
cmake_minimum_required(VERSION 2.6)
Project(Linking)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
add_custom_target(projectHeaders SOURCES AbstractPoint.h Point.h Library.h)
# Either of the following lines are ok
add_library(TestLib Library.cpp AbstractPoint.cpp Point.cpp)
ADD_EXECUTABLE(TestExe Linking.cpp)
#ADD_EXECUTABLE(TestExe Linking.cpp AbstractPoint.cpp Point.cpp)
target_link_libraries(TestExe TestLib)
#include "Library.h"
#include <iostream>
#include "Point.h"
void LibraryFunction()
{
std::cout << "LibraryFunction()" << std::endl;
}
#ifndef LIBRARY_H
#define LIBRARY_H
void LibraryFunction();
#endif
#include <iostream>
#include "Library.h"
#include "Point.h"
int main()
{
LibraryFunction();
return 0;
}
#include "Point.h"
//BOOST_CLASS_EXPORT_IMPLEMENT(Point)
#ifndef POINT_H
#define POINT_H
#include "AbstractPoint.h"
class Point : public AbstractPoint
{
public:
Point() = default;
Point(const double data) : mData(data) {}
void DoSomething(){}
double mData;
};
//BOOST_CLASS_EXPORT_KEY(Point)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment