Author Topic: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB  (Read 126 times)

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
I want to use the raylib library. But don't know how to link the lib's

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #1 on: November 23, 2022, 07:49:25 AM »
Hi Melvin and welcome to the BCX forum.

Difficult to answer, not knowing your familiarity with BCX or your experience level using compilers.

Linking a .lib can be simple or complex, depending on a library's dependencies.

Many of the samples in the BCX distribution use batch files to simplify the build process.

For example, one of the DLL samples:  Dll_Demo\ByRef-BC\ contains the following build.bat
that shows you how simple in -can- be to link in an external .lib file, in this case, a .lib file
based on BCX code.

Code: [Select]
BC mult
BC test

call pd32 mult
call pc32 test mult.lib

I've visited the raylib website and also its github site and things look very well organized.  Working
through the examples, starting with the "Creating a basic window" demo and building up from
there would be the way that I would start to gain some experience before trying to incorporate
BCX into the mix.


melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #2 on: November 23, 2022, 08:19:12 AM »
Thanks for reply, But yes i have used raylib many times. Normally we include the h file and link the *.a file. I wondering how do we add a dll or *.a file. I am super new to BCX just download it. I'm using the BCXED IDE

EDITED: Oh i have to make a bat file. Going to give that a try.
« Last Edit: November 23, 2022, 08:23:30 AM by melbot »

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #3 on: November 23, 2022, 08:30:14 AM »
I might have to go the DLL route instead of lib.a, because raylib and BCX Had some name conflicts and i had to change so function names
so using DECLARE FUNCTION XUCASE$ LIB "MyDLL.DLL" ALIAS "XUCASE"(A$) might work better just would require time to link each function. But had to change things like CloseWindow()


Or i could just rebuild the lib with the changed names

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #4 on: November 23, 2022, 08:51:27 AM »
I use the Equation Solution MINGW distribution.

Using the raylib_compile_execute.bat as a basis of understanding, I created
the following (understandable) batch file that builds the "Open a window" sample on my system.
Of special note, I had to specify M32 for gcc, as the pre-compiled libs are 32-bit.
Code: [Select]
SETLOCAL

set COMPILER_DIR=C:\mingw\bin
set PATH=%PATH%;%COMPILER_DIR%

set RAYLIB_INCLUDE_DIR=C:\raylib\src
set RAYLIB_LIB_DIR=C:\raylib\src
set RAYLIB_RES_FILE=C:\raylib\src\raylib.rc.data

set FILENAME=c:\temp\OpenWindow.c
set NAMEPART=OpenWindow

gcc -m32  -o %NAMEPART%.exe %FILENAME% %RAYLIB_RES_FILE% -s -O2 -I%RAYLIB_INCLUDE_DIR% -L%RAYLIB_LIB_DIR% -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99 -Wall -mwindows

ENDLOCAL

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #5 on: November 23, 2022, 09:33:26 AM »
Crying out Loud. So sorry for being slow. I forgot that it is a converter and not a compiler. when converting it was throwing error. but when i compile it in Visual Studio works just fine. Sorry for the bother.

edited: super new to BCX, So i going thru the doc trying to find things out.
« Last Edit: November 23, 2022, 09:52:33 AM by melbot »

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #6 on: November 23, 2022, 09:59:16 AM »
If i can bother you once more. I don't need the winapi stuff how do i take it out i tried $NOLIBRARY "kernel32.lib". But that just remove the lib

i can always just remove from the cpp. That how i got it to work. But was wondering is there a way to stop it from being included.

edited: Found it $NOWIN
« Last Edit: November 23, 2022, 10:18:27 AM by melbot »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #7 on: November 23, 2022, 10:29:36 AM »
If i can bother you once more. I don't need the winapi stuff how do i take it out i tried $NOLIBRARY "kernel32.lib". But that just remove the lib

i can always just remove from the cpp. That how i got it to work. But was wondering is there a way to stop it from being included.

edited: Found it $NOWIN

$NOWIN does control emission of headers and libs but it is important that new BCX users
understand that much (but not all) of BCX's runtime code ( in c/c++ format ) depends on the
Windows API.  That said, BCX might still be helpful generating code that you can use with
raylib and sdl.  As you mentioned that you're using the Bcx Editor (BED), you might spend
a few minutes checking out Bed.c, just to get a sense of what BCX generates.

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #8 on: November 23, 2022, 10:56:51 AM »
Thanks again. I got it working even compiling in both VSC++ and BCXED. Does BCX has TextMate?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #9 on: November 23, 2022, 11:05:20 AM »
Does BCX has TextMate?

I've never seen TextMate mentioned on any of the BCX forums.

melbot

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #10 on: November 24, 2022, 01:54:01 PM »
Thank for all the help! I have one more thing. I notice that it puts all the code in one file is that a way to have it translate to different files like: main.bas main.bi -> main.cpp main.h then i could compile them all/ link them. Is there a build in way to do this?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #11 on: November 24, 2022, 02:20:01 PM »
Thank for all the help! I have one more thing. I notice that it puts all the code in one file is that a way to have it translate to different files like: main.bas main.bi -> main.cpp main.h then i could compile them all/ link them. Is there a build in way to do this?

I think what you meant to ask is, "Is there a way to break programs into separate units?"

Yes ... look at the $PRJ and $PRJUSE directives

https://bcxbasiccoders.com/webhelp/html/directivestoc.htm

The default for BCX is to output one C/C++ file, regardless of the number of .bi, .bas, or .inc that get $INCLUDED.


jcfuller

  • Sr. Member
  • ****
  • Posts: 380
    • View Profile
Re: Can BCX USE SDL OR RAYLIB? IF SO HOW DO I IMPORT THE HEADER AND LIB
« Reply #12 on: November 24, 2022, 03:13:56 PM »
With the unique nature of all translated code placed into one file VSC++ only adds code that is used/called
to the exe. I believe I did some tests and all code is compiled and added to the exe when using several included files.
You could have a huge source code utility library file included and only the functions called are compiled.
James
« Last Edit: November 24, 2022, 03:17:32 PM by jcfuller »

Ed Davis

  • Newbie
  • *
  • Posts: 1
    • View Profile
gcc for Windows
« Reply #13 on: November 26, 2022, 07:19:04 AM »
I use the Equation Solution MINGW distribution.

Anything special with this one as compared to say TDM, WinLibs, Nuwen or MingW64 ?
Thanks!

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1431
    • View Profile
Re: gcc for Windows
« Reply #14 on: November 26, 2022, 09:10:29 AM »
I use the Equation Solution MINGW distribution.

Anything special with this one as compared to say TDM, WinLibs, Nuwen or MingW64 ?
Thanks!

Well, the producer of the Equation Solution MINGW distribution has an impressive CV.

http://www.equation.com/servlet/equation.cmd?fa=luo&lr=mx_8_48