Skip to content

Instantly share code, notes, and snippets.

@JohannesMP
Last active August 29, 2015 14:26
Show Gist options
  • Save JohannesMP/8fa140b60b8ffeb2cae0 to your computer and use it in GitHub Desktop.
Save JohannesMP/8fa140b60b8ffeb2cae0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# located in root
# cd into project directory
cd ${0%/*}
# compile library
clang++ -Wall -dynamiclib lib_src/myprint.cpp -o myprint.dylib
# compile main object file
clang++ -Wall -c main_src/main.cpp -I ./lib_src -o main.o
# link main object file and dylib
clang++ -Wall main.o myprint.dylib -o main
// Located in root/main_src
#include "../lib_src/print_lib.h"
int main(int argc, char **argv)
{
lib_print("HELLO WORLD");
}
// Located in root/lib_src
#include <iostream>
#include "print_lib.h"
void lib_print(const char *input)
{
std::cout << "lib_print: " << input << std::endl;
}
// Located in root/lib_src
#pragma once
void lib_print(const char *input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment