commit
91e2ec930e
|
@ -30,9 +30,12 @@ find_package(GTSAM REQUIRED) # Uses installed package
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# Build static library from common sources
|
# Build static library from common sources
|
||||||
set(CONVENIENCE_LIB_NAME ${PROJECT_NAME})
|
set(CONVENIENCE_LIB_NAME ${PROJECT_NAME})
|
||||||
add_library(${CONVENIENCE_LIB_NAME} STATIC example/PrintExamples.h example/PrintExamples.cpp)
|
add_library(${CONVENIENCE_LIB_NAME} SHARED example/PrintExamples.h example/PrintExamples.cpp)
|
||||||
target_link_libraries(${CONVENIENCE_LIB_NAME} gtsam)
|
target_link_libraries(${CONVENIENCE_LIB_NAME} gtsam)
|
||||||
|
|
||||||
|
# Install library
|
||||||
|
install(TARGETS ${CONVENIENCE_LIB_NAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
###################################################################################
|
###################################################################################
|
||||||
# Build tests (CMake tracks the dependecy to link with GTSAM through our project's static library)
|
# Build tests (CMake tracks the dependecy to link with GTSAM through our project's static library)
|
||||||
gtsamAddTestsGlob("example" "tests/test*.cpp" "" "${CONVENIENCE_LIB_NAME}")
|
gtsamAddTestsGlob("example" "tests/test*.cpp" "" "${CONVENIENCE_LIB_NAME}")
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# MATLAB Wrapper Example Project
|
||||||
|
|
||||||
|
This project serves as a lightweight example for demonstrating how to wrap C++ code in MATLAB using GTSAM.
|
||||||
|
|
||||||
|
## Compiling
|
||||||
|
|
||||||
|
We follow the regular build procedure inside the `example_project` directory:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
make -j8
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
sudo ldconfig # ensures the shared object file generated is correctly loaded
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Now you can open MATLAB and add the `gtsam_toolbox` to the MATLAB path
|
||||||
|
|
||||||
|
```matlab
|
||||||
|
addpath('/usr/local/gtsam_toolbox')
|
||||||
|
```
|
||||||
|
|
||||||
|
At this point you are ready to run the example project. Starting from the `example_project` directory inside MATLAB, simply run code like regular MATLAB, e.g.
|
||||||
|
|
||||||
|
```matlab
|
||||||
|
pe = example.PrintExamples();
|
||||||
|
pe.sayHello();
|
||||||
|
pe.sayGoodbye();
|
||||||
|
```
|
|
@ -18,11 +18,14 @@
|
||||||
// This is an interface file for automatic MATLAB wrapper generation. See
|
// This is an interface file for automatic MATLAB wrapper generation. See
|
||||||
// gtsam.h for full documentation and more examples.
|
// gtsam.h for full documentation and more examples.
|
||||||
|
|
||||||
|
#include <example/PrintExamples.h>
|
||||||
|
|
||||||
namespace example {
|
namespace example {
|
||||||
|
|
||||||
class PrintExamples {
|
class PrintExamples {
|
||||||
void sayHello() const;
|
PrintExamples();
|
||||||
void sayGoodbye() const;
|
void sayHello() const;
|
||||||
|
void sayGoodbye() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace example {
|
namespace example {
|
||||||
|
|
Loading…
Reference in New Issue