utils.hpp
Code: Alles auswählen
#ifndef UTILS_HEADER_GUARD
#define UTILS_HEADER_GUARD
int square(int x);
#endif
Code: Alles auswählen
#include "utils.hpp"
int square(int x) {
return x * x;
}
Code: Alles auswählen
g++ -fPIC -shared -o libUtils.so utils.cpp
Nur bekomme ich die Shared Library nicht gelinkt:
main.cpp
Code: Alles auswählen
#include <iostream>
#include "utils.hpp"
int main() {
int x = 3;
std::cout << x << "^2 = " << square(x) << std::endl;
}
Code: Alles auswählen
g++ -o main main.cpp -lUtils
/usr/bin/ld: cannot find -lUtils
collect2: ld gab 1 als Ende-Status zurück
LG Glocke