How can I fix all these undefineds in SDL2main.lib? - c++

Trying to configure SDL2 with VS Code (BTW someone should make a Youtube video on how to do this it's taken me a week and a half so far) and I thought I was almost done when these lovely errors popped up:
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_OutOfMemory]+0xf): undefined reference to `SDL_ShowSimpleMessageBox'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_utf8]+0x4): undefined reference to `SDL_SetMainReady'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xc): undefined reference to `SDL_wcslen'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0x21): undefined reference to `SDL_iconv_string'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0x3c): undefined reference to `SDL_ShowSimpleMessageBox'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xb8): undefined reference to `SDL_malloc'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xd3): undefined reference to `SDL_ShowSimpleMessageBox'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xe9): undefined reference to `SDL_SetMainReady'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xf8): undefined reference to `SDL_free'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_main_getcmdline]+0xfe): undefined reference to `SDL_free'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_wmain]+0x13): undefined reference to `SDL_malloc'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_wmain]+0x2c): undefined reference to `SDL_wcslen'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_wmain]+0x43): undefined reference to `SDL_iconv_string'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_wmain]+0x61): undefined reference to `SDL_SetMainReady'
C:/MinGW/bin/SDL2main.lib(Win32/Release/SDL_windows_main.obj):(.text[_wmain]+0x73): undefined reference to `SDL_free'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1
This is what my tasks.json file looks like:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"C:/MinGW/bin/SDL2.dll",
"C:/MinGW/bin/main.cpp",
"C:/MinGW/bin/SDL2.lib",
"C:/MinGW/bin/SDL2main.lib",
"-lmingw32",
"-mwindows"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
]
}
What am I doing to get all these errors? What must I fix about SDL2main.lib? An answer would make me very happy :)

Related

Cannot compile Stroustrup GUI Libraries

I managed to install FLTK properly and it compiles if I use library like this #include<FL/Fl_Window.H>, but now I want to compile this libraries attached below through the code provided below also;
libraries link:
https://github.com/BjarneStroustrup/Programming-_Principles_and_Practice_Using_Cpp
here are also images, shown with the errors when compiling if I will uncomment Polygon it shows different error with this content Polygon is ambiguous provided screens below also;
CODE:
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
int main()
{
using namespace Graph_lib; // our graphics facilities are in Graph_lib
Point tl {100,100}; // to become top left corner of window
Simple_window win {tl,600,400,"Canvas"}; // make a simple window
Polygon poly; // make a shape (a polygon)
poly.add(Point{300,200}); // add a point
poly.add(Point{350,100}); // add another point
poly.add(Point{400,200}); // add a third point
poly.set_color(Color::red); // adjust properties of poly
win.attach (poly); // connect poly to the window
win.wait_for_button(); // give control to the display engine
}
Error When compile code above:
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp: In function 'int main()':
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:8:5: error: reference to 'Polygon' is ambiguous
8 | Polygon poly; // make a shape (a polygon)
| ^~~~~~~
In file included from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\GUI.h:11,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Simple_window.h:2,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:1:
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Graph.h:248:8: note: candidates are: 'struct Graph_lib::Polygon'
248 | struct Polygon : Closed_polyline { // closed sequence of non-intersecting lines
| ^~~~~~~
In file included from C:/msys64/mingw64/include/windows.h:71,
from C:/msys64/mingw64/include/FL/Fl_Window.H:26,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Window.h:5,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\GUI.h:10:
C:/msys64/mingw64/include/wingdi.h:3467:28: note: 'WINBOOL Polygon(HDC, const POINT*, int)'
3467 | WINGDIAPI WINBOOL WINAPI Polygon(HDC hdc,CONST POINT *apt,int cpt);
| ^~~~~~~
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:9:5: error: 'poly' was not declared in this scope
9 | poly.add(Point{300,200}); // add a point
When Comment Out the using namespace Graph_lib
C:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp -lfltk -o C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.exe
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp: In function 'int main()':
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:8:5: error: reference to 'Polygon' is ambiguous
8 | Polygon poly; // make a shape (a polygon)
| ^~~~~~~
In file included from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\GUI.h:11,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Simple_window.h:2,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:1:
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Graph.h:248:8: note: candidates are: 'struct Graph_lib::Polygon'
248 | struct Polygon : Closed_polyline { // closed sequence of non-intersecting lines
| ^~~~~~~
In file included from C:/msys64/mingw64/include/windows.h:71,
from C:/msys64/mingw64/include/FL/Fl_Window.H:26,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Window.h:5,
from C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\GUI.h:10:
C:/msys64/mingw64/include/wingdi.h:3467:28: note: 'WINBOOL Polygon(HDC, const POINT*, int)'
3467 | WINGDIAPI WINBOOL WINAPI Polygon(HDC hdc,CONST POINT *apt,int cpt);
| ^~~~~~~
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs\Test_output.cpp:9:5: error: 'poly' was not declared in this scope
9 | poly.add(Point{300,200}); // add a point
Error When Polygon is commented just to compile code without polygon:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\AppData\Local\Temp\ccgW0oJL.o: in function `main':
C:\Users\ASUS\Desktop\C++\GUI_Train\Libs/Test_output.cpp:7: undefined reference to `Simple_window::Simple_window(Graph_lib::Point, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\Desktop\C++\GUI_Train\Libs/Test_output.cpp:14: undefined reference to `Simple_window::wait_for_button()'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\AppData\Local\Temp\ccgW0oJL.o:Test_output.cp:(.rdata$_ZTV13Simple_window[_ZTV13Simple_window]+0x20): undefined reference to `Graph_lib::Window::draw()'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\AppData\Local\Temp\ccgW0oJL.o:Test_output.cp:(.rdata$.refptr._ZTVN9Graph_lib6ButtonE[.refptr._ZTVN9Graph_lib6ButtonE]+0x0): undefined reference to `vtable for Graph_lib::Button'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ASUS\AppData\Local\Temp\ccgW0oJL.o:Test_output.cp:(.rdata$.refptr._ZTVN9Graph_lib6WindowE[.refptr._ZTVN9Graph_lib6WindowE]+0x0): undefined reference to `vtable for Graph_lib::Window'
this is my tasks:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-lfltk",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

Static linking with PreMake

First of all sorry for my bad english.
i am trying to link raylib.
Windows 10
PreMake version 5.0
g++ version 8.1.0
Directory
// premake5.lua
workspace "foo"
architecture "x64"
configurations {"Debug","Release"}
outputdir = "%{cfg.buildcfg}-%{cfg.architecture}-%{cfg.system}"
project "foo"
location "./build/"
kind "ConsoleApp"
language "C++"
targetdir "./build/%{cfg.buildcfg}"
files { "./src/**.cpp",
"./src/**.c",
"./dependencies/**.h"
}
includedirs {"./dependencies/**"}
links{"raylib"}
libdirs{"./dependencies/**"}
filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On
"```
// main.cpp
#include <iostream>
#include <raylib.h>
int main(){
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
CloseWindow();
return 0;
}```
error message:
Linking Mew
../dependencies/raylib/lib/libraylib.a(core.o):core.c:(.text+0x14dcd): undefined reference to timeEndPeriod' ../dependencies/raylib/lib/libraylib.a(core.o):core.c:(.text+0x167ca): undefined reference to timeBeginPeriod'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x16fa): undefined reference to __imp_CreateRectRgn' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x1736): undefined reference to __imp_DeleteObject'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x1791): undefined reference to __imp_SwapBuffers' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x21ce): undefined reference to __imp_GetDeviceCaps'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x27ff): undefined reference to __imp_CreateDCW' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x2813): undefined reference to __imp_GetDeviceGammaRamp'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x281c): undefined reference to __imp_DeleteDC' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6154): undefined reference to __imp_CreateDCW'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6183): undefined reference to __imp_GetDeviceCaps' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x619c): undefined reference to __imp_DeleteDC'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6308): undefined reference to __imp_GetDeviceCaps' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x633e): undefined reference to __imp_GetDeviceCaps'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6539): undefined reference to __imp_CreateDIBSection' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6573): undefined reference to __imp_CreateBitmap'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x660b): undefined reference to __imp_DeleteObject' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x6660): undefined reference to __imp_DeleteObject'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x7e89): undefined reference to __imp_CreateDCW' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x7e98): undefined reference to __imp_SetDeviceGammaRamp'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0x7ea1): undefined reference to __imp_DeleteDC' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xdcb2): undefined reference to __imp_ChoosePixelFormat'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xdcc0): undefined reference to __imp_SetPixelFormat' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xe159): undefined reference to __imp_DescribePixelFormat'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xe251): undefined reference to __imp_DescribePixelFormat' ../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xe61d): undefined reference to __imp_DescribePixelFormat'
../dependencies/raylib/lib/libraylib.a(rglfw.o):rglfw.c:(.text+0xe63c): undefined reference to `__imp_SetPixelFormat'
collect2.exe: error: ld returned 1 exit
status
mingw32-make: *** [Makefile:78: Debug/Mew.exe] Error 1
Thank you and also forgive me for my English.
a little bit late but I'll try. While compiling on Windows you need to add link libraries dependencies explicitely, especially the windows ones.
What you described are link errors. To solve the linkage problem, you have to add to link dependencies some libraries: opengl32.lib, gdi32.lib, user32.lib, ole32.lib, and optional: [netapi32.lib, Wininet.lib]
The __imp_SetPixelFormat, __imp_DescribePixelFormat, __imp_ChoosePixelFormat are defined in gdi32.lib
The __imp_SetDeviceGammaRamp is defined in opengl.lib
The __imp_DeleteObject, __imp_CreateDCW, __imp_SwapBuffers, __imp_DeleteDC are defined in the user32.lib
Hope it is useful.
PS: for runtime, make sure you have the correct redistributable (dlls).

std::variant declaration is not found by compiler

What I am trying to do is very simple, I need to create a vector that can hold different types of data. So I read about std::variant and am trying to use it, however, when declaring my "std::vector< std::variant< typenames > >", the compiler complains about not finding the declaration for variant<> even though I included the variant library.
(errors are "use of undeclared identifier variant" with implicit namespace, and "no member named 'variant' in namespace 'std'" with explicit namespace). My Clang version is 11, and I am using c++17, so I don't know what I could be missing here. For what it's worth, I am currently using VScode 1.53. This is my c_cpp_properties.json :
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
I have tried also changing the cpp version in the default GUI provided by vscode to manage the cpp compiler, that made no difference.
What I am doing is something similar to this:
#include <vector>
#include <variant>
struct c {
std::vector< std::variant<glm::vec2, glm::vec3, glm::vec4>> v;
};
Does anyone have any idea why this is happening, or had this problem before and knows a solution?
Solution:
Turns out specifying the cpp standard on the file c_cpp_properties.json is not enough. You have to add "-std=c++17" to tasks.json as well, after "-g", like this:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-g",
"-std=c++17",
...
I am not a Clang expert, but try using the option -std=c++17.
According to this the default seems to be C++98.
This appears to work fine in MSVC:
#include <variant>
struct c {
std::vector< std::variant<int, float>> v;
}
It seems like the compiler might be throwing a fit about the template type nesting(wild guess here). Maybe try the following as a workaround:
#include <variant>
struct c {
typedef std::variant< int, float> TwoPartVariant;
std::vector< TwoPartVariant> v;
};

Use sqlite3 in vscode for c++(undefined reference to `xxx')(I have use -lsqlite3)

I'm going crazy for this problem. I downloaded the source code and pre-compiled files of sqlite3 according to the tutorial, and used vs to compile, got the sqlite3.lib and sqlite3.exp files, and put it in the C: \ sql folder. Then I created the project in vscode, and put sqlite3.h in the root directory of the project, and created the following test code.
#include "sqlite3.h"
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable : 4996)
#pragma comment(lib, "c:\\sql\\sqlite3.lib")
int main() {
sqlite3 *db = NULL;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("Student.db", &db);
if (rc) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
} else
printf("open mydata successfully!\n");
sqlite3_close(db);
system("pause");
return 0;
}
My tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "gdb",
"type": "shell",
"command": "g++",
"args": [
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-LC:\\sql",
// "${fileDirname}\\src\\Account.cpp",
// "${fileDirname}\\src\\Person.cpp",
// "${fileDirname}\\src\\Date.cpp",
// "${fileDirname}\\src\\System.cpp",
// "${fileDirname}\\src\\Administrator.cpp",
"-lsqlite3",
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
But no matter how I modify the tasks.json file, I still get the following result. I am really too lost. Can anyone help me how to solve this problem?
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Drew\AppData\Local\Temp\ccUXavQh.o:test.cpp:(.text+0x2e): undefined reference to `sqlite3_open'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Drew\AppData\Local\Temp\ccUXavQh.o:test.cpp:(.text+0x45): undefined reference to `sqlite3_errmsg'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Drew\AppData\Local\Temp\ccUXavQh.o:test.cpp:(.text+0x6d): undefined reference to `sqlite3_close'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Drew\AppData\Local\Temp\ccUXavQh.o:test.cpp:(.text+0x91): undefined reference to `sqlite3_close'
collect2.exe: error: ld returned 1 exit status
I personally download the sqlite-amalgamation source and compile it as a regular source file. SQLite made it very easy and you should have no problem https://www.sqlite.org/download.html
I don't mess with static/dynamic libs when I don't need to. The problem may occur because of which compiler compiled the library (ie ms compiler, mingw, clang, etc). There's a chance you may be mixing them causing the error. I suspect the precompile one is using ms compiler. From memory clang works with libs compiled with ms compiler (clang depends on it). mingw doesn't depend on it and won't use ms compiled libs

gcc Linker and OGDF "undefined reference to `ogdf::Initialization::Initialization()'"

I am trying to get OGDF working to see if it is suitable for my project, but I am having trouble with a sample program.
I am trying to compile this example program:
#include <ogdf/basic/Graph.h>
#include <ogdf/basic/graph_generators.h>
#include <ogdf/layered/DfsAcyclicSubgraph.h>
using namespace ogdf;
int main()
{
Graph G;
randomSimpleGraph(G, 10, 20);
DfsAcyclicSubgraph DAS;
DAS.callAndReverse(G);
G.writeGML("test.gml");
return 0;
}
using this command:
$g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ -lOGDF test2.cpp
But I get the following error
/tmp/ccbpkfdt.o: In function `main':
test2.cpp:(.text+0x12): undefined reference to `ogdf::Graph::Graph()'
test2.cpp:(.text+0x2e): undefined reference to `ogdf::randomSimpleGraph(ogdf::Graph&, int, int)'
test2.cpp:(.text+0x4e): undefined reference to `ogdf::AcyclicSubgraphModule::callAndReverse(ogdf::Graph&)'
test2.cpp:(.text+0x62): undefined reference to `ogdf::Graph::writeGML(char const*) const'
test2.cpp:(.text+0x7f): undefined reference to `ogdf::Graph::~Graph()'
test2.cpp:(.text+0xa1): undefined reference to `ogdf::Graph::~Graph()'
/tmp/ccbpkfdt.o: In function `__static_initialization_and_destruction_0(int, int)':
test2.cpp:(.text+0xfb): undefined reference to `ogdf::Initialization::Initialization()'
test2.cpp:(.text+0x112): undefined reference to `ogdf::Initialization::~Initialization()'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphC2Ev[_ZN4ogdf18DfsAcyclicSubgraphC5Ev]+0x16): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
/tmp/ccbpkfdt.o: In function `ogdf::DfsAcyclicSubgraph::~DfsAcyclicSubgraph()':
test2.cpp:(.text._ZN4ogdf18DfsAcyclicSubgraphD2Ev[_ZN4ogdf18DfsAcyclicSubgraphD5Ev]+0xb): undefined reference to `vtable for ogdf::DfsAcyclicSubgraph'
collect2: error: ld returned 1 exit status
I tried compiling hello world, with an include from OGDF, and I still got:
undefined reference to `ogdf::Initialization::Initialization()'
I think I am not linking properly or something?
You have to be very careful in which order you type stuff when linking with a library.
Try putting test2.cpp before -lOGDF instead, like this:
g++ -pthread -I ./OGDF/ -L ./OGDF/_release/ test2.cpp -lOGDF
You must build your program using the -DOGDF_DLL when using OGDF as a shared library.
See here: http://www.ogdf.net/doku.php/tech:defines