Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using gcc to compile C file
#1
hi
is it possible to use gcc from qb64 internal\c-compiler\bin
to compile C file  ?
maybe with Notepad++ ?

any clue ?

i am lazy to download whole MingW
Reply
#2
You can.

Assuming you are in the QB64pe directory, simply run gcc like: .\internal\c\c_compiler\bin\gcc

Or you could just use the absolute path.


[Image: Screenshot-2024-04-19-010640.png]
Reply
#3
Quote:i am lazy to download whole MingW
@aurel - You don't have to download it, a program does it.  Cool

When I read "i am lazy to . . ." this is what comes to mind:  

Der Struwwelpeter/Die Geschichte vom Suppen-Kaspar  Tongue
Reply
#4
Heh OK

But yes ..i really mean ...why download and install mingw

IF i already have it in QB64pe folder...

what you posted is image on imgbb is simply to small
so again ...do i use Notepad++ to force gcc to compile C file
i mean how... using ShellExecute() or with some another trick maybe ?
Reply
#5
Ok i found something on Stackoverflow
in my case i copy whole c_compiler folder into disk D:\

"D:\c_compiler\bin\gcc.exe" "$(FULL_CURRENT_PATH)" -o "$(CURRENT_DIRECTORY)"\$(NAME_PART).exe"

and add this to Notepad++ Run input dialog
and voila my C file as test1.c is compiled into excutable
Smile
Reply
#6
(04-19-2024, 06:49 AM)aurel Wrote: Heh OK

But yes ..i really mean ...why download and install mingw

IF i already have it in QB64pe folder...

so again ...do i use Notepad++ to force gcc to compile C file
i mean how... using ShellExecute() or with some another trick maybe ?
As described here: https://qb64phoenix.com/forum/showthread...2#pid24432
Reply
#7
Ok
i don't know for this topic
also why must be latest, C is a C ...not C++ which
have lot of versions
Reply
#8
(04-19-2024, 11:47 AM)aurel Wrote: also why must be latest, C is a C ...not C++ which
have lot of versions
For the same reason why there are updates to QB64pe. - There are also constant updates to the C compilers, not just for C++. Once because of improvements, and then when there are changes to the norm.
*)You can delete the C stuff in QB64. To program in C/C++ you use MinGW. There are also programs that require a C compiler.

*)There is a good program from . . . I can't find it right now.
Reply
#9
(04-19-2024, 08:12 AM)aurel Wrote: Ok i found something on Stackoverflow
in my case i copy whole c_compiler folder into disk D:\

"D:\c_compiler\bin\gcc.exe" "$(FULL_CURRENT_PATH)" -o "$(CURRENT_DIRECTORY)"\$(NAME_PART).exe"
I just noticed it now - it looks wild.  Sad
If you have installed MingW, you still have to create the path so that one can call the compiler from any directory. Like This:

[Image: Compiler-Pfad.jpg]
Reply
#10
The MinGW compiler installed with QB64PE is perfectly functional, so there is no need to waste several hundred megabytes of disk space on another MinGW version unless you need a specific compiler.

Here's a batch file I use that allows a user to compile C or C++ programs using QB64PE's MinGW.  It will invoke the appropriate compiler, GCC.EXE or G++.EXE, depending on the extension of your source file.

It can be used from the command line ("CCOMP.BAT hello.c"), but it can also be used drag-and-drop style: in your file manager, drag your C file onto the compiler .BAT file.

This batch file is designed to work from the QB64PE directory or from the MinGW subdirectory.



Code: (Select All)
@echo off
SETLOCAL ENABLEEXTENSIONS


REM v2024.04.21, JSR.
REM Public Domain.  Feel free to adapt it to your purposes.



REM About:
REM Designed to be run from within the main directory of any MinGW installation.
REM Can also be run from within QB64PE's directory, where it will find
REM and use the MinGW version that was installed along with QB64PE.
REM Also works with mstorsjo's CLang builds.
REM Not tested on other CLang builds.



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Note: GCC options -m32 & -m64 don't work with MinGW compilers    ::
::       that use SEH or Dwarf2 exception handling.                 ::
::       These versions of MinGW can only create an executable with ::
::       the same word size as themselves.                          ::
::       (QB64PE currently uses an SEH-based compiler)              ::
::       To make use of -m32 & -m64 you need a compiler that uses   ::
::       SJLJ exception handling.                                   ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


REM The "set copts=" line allows you to set your preferred compiler options.


cls
if not "%~1"=="" goto lunch
echo.
echo Compile using QB64PE's included MinGW C/C++ compiler.
echo.
echo This batch script will invoke either gcc.exe (for .c source)
echo or g++.exe (for .cpp source) using preset compiler options.
echo It can first set any needed or desired environment variables.
echo.
echo If run from the command prompt,
echo additional options may be given by the user.
echo.
echo Usage: %~nx0 ^<filename^> [opt] [opt] [opt] [opt] [opt] ...
echo        (or drag your C/C++ source file onto %~nx0 in your file manager)
echo.
echo.
goto hawaii


:lunch
REM Auto-select C or C++ compiler....
set ccomp=gcc.exe
if /i "%~x1"==".cpp" set ccomp=g++.exe


REM Set copts to your preferred compiler options....
set copts=-Os -s -Wall -static
REM (Add -mwindows to copts to create a Windows GUI executable)


REM Let's figure out where the compiler is...
if not "%MGWDIR%"=="" goto work
REM ...start by assuming we're in the MinGW directory....
set MGWDIR=%~dp0
REM (MGWDIR is not needed by the compiler; it is for our use)
REM ...then check to see if we are really in the QB64PE directory....
if exist "%~dp0internal\c\c_compiler\" set MGWDIR=%~dp0internal\c\c_compiler


REM Set any needed or desired environment variables....
REM GCC does not really need PATH, but we'll set it anyway.
REM (Doing this makes it easier to adapt this script for other compilers which DO need PATH)
set PATH=%MGWDIR%\bin;%PATH%


:work
REM Let the compiler do its thing....
echo Compiling:
echo "%ccomp%" "%~1" -o "%~dpn1.exe" %copts% %2 %3 %4 %5 %6 %7 %8 %9
echo.
echo.
"%ccomp%" "%~1" -o "%~dpn1.exe" %copts% %2 %3 %4 %5 %6 %7 %8 %9
if exist "%~dpn1.exe" echo ---^>^  "%~dpn1.exe" created.
if not exist "%~dpn1.exe" echo ---^>^ "%~dpn1.exe" NOT created.


REM If your compiler leaves behind any extra files that you want automatically deleted, delete them here....
REM (the 3 examples below are commented out.  Feel free to change or replace them)
::del "%~dpn1.obj" 2>nul        :: Delete <YourProgramName.obj> file....
::del "%~dpn1.map" 2>nul        :: Delete <YourProgramName.map> file....
::del "%~dpn1.tds" 2>nul        :: Delete <YourProgramName.tds> file....
REM DEL will complain if its target file does not exist, so
REM the example lines above send DEL's error messages to NUL ("2>nul").
REM Doing this causes DEL to fail silently if the target files don't exist.


:hawaii
pause
Reply




Users browsing this thread: 2 Guest(s)