Heya,
I want to compile a simple Main class using SFML from terminal but I'm getting the no undefined symbols error.
I have put the frame works in the correct places and the include statement isn't giving me any error.
Undefined symbols for architecture x86_64:
"sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)", referenced from:
_main in Main-66feaa.o
"sf::RenderWindow::~RenderWindow()", referenced from:
_main in Main-66feaa.o
"sf::String::String(char const*, std::__1::locale const&)", referenced from:
_main in Main-66feaa.o
"sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
_main in Main-66feaa.o
The main class is:
#include <iostream>
#include <vector>
#include "Mechanics.hpp"
#include <SFML/Graphics.hpp>
int main() {
std::cout << "Hello Elliot" << std::endl;
Mechanics *mech = new Mechanics();
int f = 5;
int m = 10;
double force = (*mech).force(f, m);
std:: cout << force << std::endl;
double vel = (*mech).velocityTime(5, 9.81, 30);
std::cout << vel << std::endl;
sf::RenderWindow window(sf::VideoMode(800, 600), "Pls Wrk");
return 0;
}
g++ version:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
It would be a massive help if anyone could tell how to compile this from terminal,
I'm pretty new to c++.
Thanks,
Rainy
Thank you yes that was it.
Just for everyone else, if you have put the libraries in the right places then all you need to do is use -c flag when compiling as follows:
g++ -c <yourfile>
Otherwise
g++ <yourfile> -L <path to library folder> -l<libraryname>
For all your libraries. Note is your library is called: libsfml-window.dylib then the command is: -lsfml-window
ignoring the "lib" at the front and the ".dylib" at the end. You must do this for every every library you use.
Also I THINK the command for for include folder is -I but i haven't had to use it.
Just remember when using -I it should come before <yourfile>
Note: This is for Mac OS X with the g++ compiler.
Thank you everyone,
Rainy