Skip to content

Commit

Permalink
Merge pull request #70 from opennars/MorePortableLibraryUsage
Browse files Browse the repository at this point in the history
Update: Make at least static linking easy as dynamic linking works di…
  • Loading branch information
patham9 authored Jun 22, 2020
2 parents 964d82e + 7c090ab commit fee8867
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mv src/main_ src/main.c
sudo rm -rf /usr/local/include/ona
sudo rm /usr/local/lib/libONA.a
sudo rm /usr/local/lib/libONA.so
set -e
Str=`ls src/*.c src/NetworkNAR/*.c | xargs`
echo $Str
echo "Compilation started:"
Expand All @@ -28,4 +27,5 @@ sudo mkdir /usr/local/include/ona/NetworkNAR/
sudo cp src/NetworkNAR/*.h /usr/local/include/ona/NetworkNAR/
sudo cp *.a /usr/local/lib/
sudo cp *.so /usr/local/lib/
mv src/main_ src/main.c
echo "Done."
5 changes: 3 additions & 2 deletions misc/C/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdio.h>
#include "ona/NAR.h"
#include "./../../src/NAR.h"
//#include <ona/NAR.h>

bool executed = false;
void NAR_Op()
Expand All @@ -14,6 +15,6 @@ int main()
NAR_AddInputNarsese("<(a &/ ^op) =/> g>.");
NAR_AddInputNarsese("a. :|:");
NAR_AddInputNarsese("g! :|:");
assert(executed, "Eecution should have happened!");
Globals_assert(executed, "Eecution should have happened!");
return 0;
}
7 changes: 4 additions & 3 deletions misc/CPP/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <iostream>
//namespace ona { //if used with other namespaces
extern "C" {
#include "ona/NAR.h"
//#undef assert //for ROS
#include "./../../src/NAR.h"
//#include <ona/NAR.h>
#undef assert //for ROS and Mac
}
//}
//using namespace ona;
Expand All @@ -20,6 +21,6 @@ int main()
NAR_AddInputNarsese((char*) "<(a &/ ^op) =/> g>.");
NAR_AddInputNarsese((char*) "a. :|:");
NAR_AddInputNarsese((char*) "g! :|:");
assert(executed, (char*) "Eecution should have happened!");
Globals_assert(executed, (char*) "Eecution should have happened!");
return 0;
}
2 changes: 1 addition & 1 deletion src/Globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <stdio.h>
#include <stdlib.h>

void assert(bool b, char* message)
void Globals_assert(bool b, char* message)
{
if(!b)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
#endif
#define IN_DEBUG(x) {if(DEBUG){ x } }
//assert, printing message and exiting if b=false
void assert(bool b, char* message);
void Globals_assert(bool b, char* message);
#define assert Globals_assert
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
//Number of elements of compile time allocated array:
Expand Down

0 comments on commit fee8867

Please sign in to comment.