Author Topic: Code seperate from headerfile (.h and .cpp) -> no reference to function...  (Read 222 times)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5068
  • O Rly?
    • View Profile
Hi,

simple to reproduce:

test.h:
Code: (glbasic) [Select]
int addStuff(int x, int y);
}

test.cpp:
Code: (glbasic) [Select]
#inlude "test.h"

int addStuff(int x, int y) {
return x + y;
}


glbasic:
Code: (glbasic) [Select]
INLINE
}
#include "test.h"

namespace __GLBASIC__{
ENDINLINE

FUNCTION TEST_addStuff: x, y
INLINE
return addStuff(x, y);
ENDINLINE
ENDFUNCTION


Result:
undefined reference to `addStuff(int, int)'

cpp-files seems to be ignored!

Is this new or i be stupid right now?!
« Last Edit: 2020-May-02 by Schranz0r »
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 266
  • UNUS SED LEO
    • View Profile
so it works:

test.cpp:
Code: (glbasic) [Select]
extern "C"    int addStuff(int x, int y) {
return x + y;
}


GlBasic
Code: (glbasic) [Select]
REQUIRE "test.cpp"
IMPORT "C" int addStuff(int x, int y)
PRINT addStuff(1340,220),60,50
SHOWSCREEN
SLEEP 6000
END

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5068
  • O Rly?
    • View Profile
I know but make no sens...
On my project i get multiple errors with this method ^^

Attached the GLFW and ImGUI Project...
Error on IMGUI.gbas :/

EDIT: To run correctly you have edit Projects->Options->INK the Path to the folder!
« Last Edit: 2020-May-02 by Schranz0r »
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 365
    • View Profile
    • my personal website
Nice inline stuff, but that quest is to hard and this ImGui library looks strange, so many build/include options oh..
Briefly looked at it, and from one hand it doesn't have it's own lib/a file, but when checking some makefiles that people are using to build apps with it - they are including main cpp files as a library:
for example:
add_library(${PROJECT_NAME}
  src/dynamic_reconfigure.cpp
  src/imgui_ros.cpp
  src/image.cpp
  imgui/imgui.cpp
  imgui/imgui_demo.cpp
  imgui/imgui_draw.cpp
  imgui/imgui_widgets.cpp
  imgui/examples/imgui_impl_sdl.cpp
  imgui/examples/imgui_impl_opengl3.cpp
  imgui/examples/libs/gl3w/GL/gl3w.c
)
and somwehere there is also: "/devel/lib/libimgui/imgui.cpp.so" so it look's like sources need to be compiled as lib file or included somehow in link stage...
Checked some tutorials for that lib, it should be easy to use it, but all of them are using makefiles, not direct g++ command lines. That's best in such solutions, over complicating simple thing in a way so it's hard to bite it..

btw. inline in GLB can be tricky :D
Check my source code editor for GLBasic - link Update: 20.04.2020