Using advanced constructors to convert array to armadillo vec - c++

I am trying to convert an object of type ODE_vector to an armadillo vec such that the new object will inherit the linear algebraic functionality of the armadillo library. As a simple example of the problem I am having this is a demonstration using a C++ array:
#include <iostream>
#include <random>
#include <armadillo>
using namespace std;
using namespace arma;
int main() {
double b1 = 0.2;
double b2 = 0.1;
const double state[2] = {b1, b2};
rowvec B(&state[0], 2);
cout << B << endl;
mat A(2,2); A.fill(0.2); A.diag().ones();
cout << A << endl;
cout << B(0) * A(0,0) << endl; // x
return 0;
}
The data contained in b1 and b2 is saved in the elements of B so that running this script returns the following:
0.2000
0.1000
1.0000 0.2000
0.2000 1.0000
0.2
HOWEVER, if I replace line x above with
cout << B * A << endl;
I get errors suggesting B has not inherited the standard armadillo linear algebra functionality:
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
[100%] Linking CXX executable untitled
CMakeFiles/untitled.dir/main.cpp.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
/usr/include/armadillo_bits/wrapper_blas.hpp:36: undefined reference to `wrapper_dgemv_'
CMakeFiles/untitled.dir/main.cpp.o: In function `void arma::blas::gemm<double>(char const*, char const*, int const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
/usr/include/armadillo_bits/wrapper_blas.hpp:71: undefined reference to `wrapper_dgemm_'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled.dir/build.make:94: recipe for target 'untitled' failed
make[3]: *** [untitled] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/untitled.dir/rule' failed
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
Makefile:118: recipe for target 'untitled' failed
make: *** [untitled] Error 2
Can anyone explain how to properly use the advanced constructors (arma documentation) to get this working?
Thanks

You need to have the right format in the multiplication. Type B is a 2x1 and A is 2x2. Change to
mat B(&state[0], 1,2);
or
rowvec B(&state[0], 2);

Related

building Gtest framework in LINUX

I have downloaded the GTest sourcecode googletest-release-1.8.0.tar.gz (from : github ) and extracted it. (working on CentOS)
After that I ran following commands:
cd googletest-release-1.8.0\googletest.
cmake CMakeLists.txt.
Output:
-- Configuring done
-- Generating done
-- Build files have been written to: gtestframework/googletest-release-1.8.0/googletest
make.
Output:
[ 50%] Built target gtest
[100%] Built target gtest_main
After this I copied the file libgtest_main.a and libgtest.a into /usr/lib.
cd googletest-release-1.8.0\googlemock\gtest.
Copied libgtest_main.so libgtest.so libGTest.so in /usr/lib folder.
cd gtestframework\Testcode //{2 C++ files inside Testcode}
cmake CMakeLists.txt.
make.
I got this error:
Linking CXX executable runTests
CMakeFiles/runTests.dir/tests.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
tests.cpp:(.text+0x95a): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
tests.cpp:(.text+0xa14): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles/runTests.dir/tests.cpp.o: In function `testing::AssertionResult testing::internal::CmpHelperEQFailure<int, double>(char const*, char const*, int const&, double const&)':
tests.cpp:(.text._ZN7testing8internal18CmpHelperEQFailureIidEENS_15AssertionResultEPKcS4_RKT_RKT0_[_ZN7testing8internal18CmpHelperEQFailureIidEENS_15AssertionResultEPKcS4_RKT_RKT0_]+0x6c): undefined reference to `testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
CMakeFiles/runTests.dir/tests.cpp.o: In function `testing::AssertionResult testing::internal::CmpHelperEQFailure<double, double>(char const*, char const*, double const&, double const&)':
tests.cpp:(.text._ZN7testing8internal18CmpHelperEQFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_[_ZN7testing8internal18CmpHelperEQFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_]+0x6c): undefined reference to `testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [runTests] Error 1
make[1]: *** [CMakeFiles/runTests.dir/all] Error 2
make: *** [all] Error 2
CMakeLists.txt file content:
cmake_minimum_required(VERSION 2.6)
# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
# Link runTests with what we want to test and the GTest and pthread library
add_executable(runTests tests.cpp)
target_link_libraries(runTests ${GTEST_LIBRARIES} pthread)

Matrix multiplication not working in C++ armadillo

I am using armadillo in C++ and have a very simple issue - can someone please explain to me why I am unable to calculate XtX? I am multiplying a 2x3 and a 3x2 matrix and as soon as I add the last line, the code does not build.
mat X(3,2);
X="1 3; 1 2; 1 5";
mat Xt;
Xt=X.t();
mat XtX(2,2);
XtX=Xt*X;
This is the error I get:
[build] CMakeFiles\MoE.dir/objects.a(main.cpp.obj): In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)':
[build] C:/Users/.../include/armadillo_bits/wrapper_blas.hpp:42: undefined reference to `wrapper_dgemv_'

compiling gtest and gmock examples

I have a book, Modern C++ programming with Test-Driven Development and i want to build the examples from the book, im using google mock 1.6.0 and google test 1.6.0 and i get the following error when i try to build
please help!!
[ 14%] Linking CXX executable test
CMakeFiles/test.dir/CharUtilTest.cpp.o: In function `AChar_IsAVowelForSixSpecificLetters_Test::TestBody()':
CharUtilTest.cpp:(.text+0x78): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x160): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x248): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x330): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CharUtilTest.cpp:(.text+0x418): undefined reference to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)'
CMakeFiles/test.dir/CharUtilTest.cpp.o:CharUtilTest.cpp:(.text+0x500): more undefined references to `testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)' follow
CMakeFiles/test.dir/CharUtilTest.cpp.o: In function `__static_initialization_and_destruction_0(int, int)':
CharUtilTest.cpp:(.text+0x18fc): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1954): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x19ac): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1a04): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CharUtilTest.cpp:(.text+0x1a5c): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles/test.dir/CharUtilTest.cpp.o:CharUtilTest.cpp:(.text+0x1ab4): more undefined references to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' follow
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::Log(testing::internal::LogSeverity, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
gmock-all.cc:(.text+0xdc1): undefined reference to `testing::internal::GetCurrentOsStackTraceExceptTop(testing::UnitTest*, int)'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::ParseGoogleMockFlagValue(char const*, char const*, bool)':
gmock-all.cc:(.text+0x44f2): undefined reference to `testing::internal::String::Format(char const*, ...)'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::internal::String::operator==(char const*) const':
gmock-all.cc:(.text._ZNK7testing8internal6StringeqEPKc[_ZNK7testing8internal6StringeqEPKc]+0x42): undefined reference to `testing::internal::String::Compare(testing::internal::String const&) const'
/home/matthew/googlemock-release-1.6.0/mybuild/libgmock.a(gmock-all.cc.o): In function `testing::Message::operator<<(wchar_t*)':
gmock-all.cc:(.text._ZN7testing7MessagelsEPw[_ZN7testing7MessagelsEPw]+0x2f): undefined reference to `testing::internal::String::ShowWideCString(wchar_t const*)'
collect2: error: ld returned 1 exit status
CMakeFiles/test.dir/build.make:158: recipe for target 'test' failed
make[2]: *** [test] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test.dir/all' failed
make[1]: *** [CMakeFiles/test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
.
matthew#Matthew:~/code/c2/40/build$ make VERBOSE=1
/usr/local/bin/cmake -H/home/matthew/code/c2/40 -B/home/matthew/code/c2/40/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/matthew/code/c2/40/build/CMakeFiles /home/matthew/code/c2/40/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/matthew/code/c2/40/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/depend
make[2]: Entering directory '/home/matthew/code/c2/40/build'
cd /home/matthew/code/c2/40/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/matthew/code/c2/40 /home/matthew/code/c2/40 /home/matthew/code/c2/40/build /home/matthew/code/c2/40/build /home/matthew/code/c2/40/build/CMakeFiles/test.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/matthew/code/c2/40/build'
make -f CMakeFiles/test.dir/build.make CMakeFiles/test.dir/build
make[2]: Entering directory '/home/matthew/code/c2/40/build'
[ 14%] Linking CXX executable test
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++ -Wall -rdynamic CMakeFiles/test.dir/CharUtilTest.cpp.o CMakeFiles/test.dir/SoundexTest.cpp.o CMakeFiles/test.dir/StringUtilTest.cpp.o CMakeFiles/test.dir/main.cpp.o CMakeFiles/test.dir/CharUtil.cpp.o CMakeFiles/test.dir/StringUtil.cpp.o -o test -L/home/matthew/googletest-release-1.8.0/googlemock/build -L/home/matthew/googletest-release-1.8.0/googlemock/gtest/mybuild -Wl,-rpath,/home/matthew/googletest-release-1.8.0/googlemock/build:/home/matthew/googletest-release-1.8.0/googlemock/gtest/mybuild -lpthread -lgmock -lgtest
/usr/bin/ld: cannot find -lgmock
collect2: error: ld returned 1 exit status
CMakeFiles/test.dir/build.make:158: recipe for target 'test' failed
make[2]: *** [test] Error 1
make[2]: Leaving directory '/home/matthew/code/c2/40/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/test.dir/all' failed
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory '/home/matthew/code/c2/40/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Error when linking gtest project

recently I start study unit testing , and I want test my program with gtest. I install all with this order :
$ git clone https://github.com/google/googletest
$ cd googletest
$ cmake -DBUILD_SHARED_LIBS=ON .
$ make
$ cd googlemock
$ sudo cp ./libgmock_main.so ./gtest/libgtest.so gtest/libgtest_main.so ./libgmock.so /usr/lib/
$ sudo ldconfig
and now write code :
#include "gtest/gtest.h"
class Add
{
private:
int element;
public:
Add():element(0){}
~Add(){}
void setElement(int e){ element = e; }
int getElement() { return element; }
int adder(int e) { return element += e; }
};
class AddTest : public ::testing::Test
{
protected:
int abc(int a){
return a;
}
virtual void SetUp(){
add1.setElement(1);
add2.setElement(20);
}
virtual void TearDown(){}
Add add1;
Add add2;
};
TEST_F(AddTest, getTest)
{
EXPECT_EQ(1, add1.getElement());
EXPECT_EQ(20, add2.getElement());
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
end when I run test i get this error :
CMakeFiles/mock2.dir/main.cpp.o: In function AddTest_getTest_Test::TestBody()':
/home/artem/CLionProjects/mock2/main.cpp:33: undefined reference totesting::Message::Message()'
/home/artem/CLionProjects/mock2/main.cpp:33: undefined reference to testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/home/artem/CLionProjects/mock2/main.cpp:33: undefined reference totesting::internal::AssertHelper::operator=(testing::Message const&) const'
/home/artem/CLionProjects/mock2/main.cpp:33: undefined reference to testing::internal::AssertHelper::~AssertHelper()'
/home/artem/CLionProjects/mock2/main.cpp:34: undefined reference totesting::Message::Message()'
/home/artem/CLionProjects/mock2/main.cpp:34: undefined reference to testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/home/artem/CLionProjects/mock2/main.cpp:34: undefined reference totesting::internal::AssertHelper::operator=(testing::Message const&) const'
/home/artem/CLionProjects/mock2/main.cpp:34: undefined reference to testing::internal::AssertHelper::~AssertHelper()'
/home/artem/CLionProjects/mock2/main.cpp:33: undefined reference totesting::internal::AssertHelper::~AssertHelper()'
/home/artem/CLionProjects/mock2/main.cpp:34: undefined reference to testing::internal::AssertHelper::~AssertHelper()'
CMakeFiles/mock2.dir/main.cpp.o: In functionmain':
/home/artem/CLionProjects/mock2/main.cpp:39: undefined reference to testing::InitGoogleTest(int*, char**)'
CMakeFiles/mock2.dir/main.cpp.o: In function__static_initialization_and_destruction_0(int, int)':
/home/artem/CLionProjects/mock2/main.cpp:31: undefined reference to testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles/mock2.dir/main.cpp.o: In functionRUN_ALL_TESTS()':
/usr/local/include/gtest/gtest.h:2235: undefined reference to testing::UnitTest::GetInstance()'
/usr/local/include/gtest/gtest.h:2235: undefined reference totesting::UnitTest::Run()'
CMakeFiles/mock2.dir/main.cpp.o: In function AddTest::AddTest()':
/home/artem/CLionProjects/mock2/main.cpp:15: undefined reference totesting::Test::Test()'
CMakeFiles/mock2.dir/main.cpp.o: In function AddTest::~AddTest()':
/home/artem/CLionProjects/mock2/main.cpp:15: undefined reference totesting::Test::~Test()'
CMakeFiles/mock2.dir/main.cpp.o: In function testing::internal::scoped_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::reset(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)':
/usr/local/include/gtest/internal/gtest-port.h:1172: undefined reference totesting::internal::IsTrue(bool)'
CMakeFiles/mock2.dir/main.cpp.o: In function testing::internal::scoped_ptr<std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> > >::reset(std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)':
/usr/local/include/gtest/internal/gtest-port.h:1172: undefined reference totesting::internal::IsTrue(bool)'
CMakeFiles/mock2.dir/main.cpp.o: In function testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)':
/usr/local/include/gtest/gtest.h:1394: undefined reference totesting::AssertionSuccess()'
CMakeFiles/mock2.dir/main.cpp.o: In function testing::AssertionResult testing::internal::CmpHelperEQFailure<int, int>(char const*, char const*, int const&, int const&)':
/usr/local/include/gtest/gtest.h:1384: undefined reference totesting::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, bool)'
CMakeFiles/mock2.dir/main.cpp.o:(.rodata._ZTI7AddTest[_ZTI7AddTest]+0x10): undefined reference to `typeinfo for testing::Test'
collect2: error: ld returned 1 exit status
CMakeFiles/mock2.dir/build.make:94: recipe for target 'mock2' failed
make[3]: * [mock2] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mock2.dir/all' failed
make[2]: [CMakeFiles/mock2.dir/all] Error 2
CMakeFiles/Makefile2:79: recipe for target 'CMakeFiles/mock2.dir/rule' failed
make[1]: [CMakeFiles/mock2.dir/rule] Error 2
Makefile:118: recipe for target 'mock2' failed
make: * [mock2] Error 2
but when use command
g++ main.cpp -o test -lgtest -lpthread
everytheng is good. How can I fix it and run it not in command line ?
If you are using CLion then you may have a CMakeLists.txt file you should add rules to link to the libraries. To do this add the following line to your CMakeLists.txt
enable_testing()
find_package(GTest REQUIRED) # Find the google testing framework on your system
include_directories(${GTEST_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBRARIES}) # Replace ${PROJECT_NAME} with your target name
For more details go here.

Armardillo with Eclipse

I have installed Armadillo in Ubuntu 14.10. I have an example code likes below
#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;
int main(int argc, char** argv)
{
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);
cout << A*B.t() << endl;
return 0;
}
I compiled in command line, it is always successful, I depict in captured image.
I have eclipse Luna for C++ and config in C/C++ Build Settings
As you can see, it is similar to command line but when eclipse compiles, it use -Iarmadillo instead of -larmadillo and it then occurs errors.
The errors were
make all Building file: ../src/Test.cpp Invoking: GCC C++ Compiler
g++ -std=c++0x -Iarmadillo -O0 -MMD -MP -MF"src/Test.d"
-MT"src/Test.d" -o "src/Test.o" "../src/Test.cpp" /tmp/ccy9M8WG.o: In function void arma::blas::gemv<double>(char const*, int const*, int
const*, double const*, double const*, int const*, double const*, int
const*, double const*, double*, int const*)':
Test.cpp:(.text._ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_[_ZN4arma4blas4gemvIdEEvPKcPKiS5_PKT_S8_S5_S8_S5_S8_PS6_S5_]+0x55):
undefined reference towrapper_dgemv_' /tmp/ccy9M8WG.o: In function
void arma::blas::gemm<double>(char const*, char const*, int const*,
int const*, int const*, double const*, double const*, int const*,
double const*, int const*, double const*, double*, int const*)':
Test.cpp:(.text._ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_[_ZN4arma4blas4gemmIdEEvPKcS3_PKiS5_S5_PKT_S8_S5_S8_S5_S8_PS6_S5_]+0x5b):
undefined reference towrapper_dgemm_' /tmp/ccy9M8WG.o: In function
void arma::blas::syrk<double>(char const*, char const*, int const*,
int const*, double const*, double const*, int const*, double const*,
double*, int const*)':
Test.cpp:(.text._ZN4arma4blas4syrkIdEEvPKcS3_PKiS5_PKT_S8_S5_S8_PS6_S5_[_ZN4arma4blas4syrkIdEEvPKcS3_PKiS5_PKT_S8_S5_S8_PS6_S5_]+0x4e):
undefined reference towrapper_dsyrk_' /tmp/ccy9M8WG.o: In function
double arma::blas::dot<double>(unsigned int, double const*, double
const*)':
Test.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[_ZN4arma4blas3dotIdEET_jPKS2_S4_]+0x4a):
undefined reference towrapper_ddot_' /tmp/ccy9M8WG.o: In function
TLS wrapper function for arma::arma_rng_cxx11_instance':
Test.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x5):
undefined reference toTLS init function for
arma::arma_rng_cxx11_instance'
Test.cpp:(.text._ZTWN4arma23arma_rng_cxx11_instanceE[_ZTWN4arma23arma_rng_cxx11_instanceE]+0x15):
undefined reference to `arma::arma_rng_cxx11_instance' collect2:
error: ld returned 1 exit status src/subdir.mk:18: recipe for target
'src/Test.o' failed make: *** [src/Test.o] Error 1
My questions are
How can I force eclipse use -larmadillo?
What happened to this phenomenon?
Thank you in advance
You can also create GNU Autotools projects and add following line:
bin_PROGRAMS=armadillo_example
armadillo_example_SOURCES=armadillo_example.cpp
armadillo_example_LDADD=-larmadillo
To Makefile.am file where your source code exist.
You may not be linking with Armadillo. Use -larmadillo in your link as Hamed suggested.