Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-05

problem with the opengl unit

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

YuGiOhJCJ Mailing-List

Hello,

I have built from source code the fpc-2.6.4 compiler on Linux. I am not sure that I have correctly build it because:

1) It works well with my hello_world.pas code:
program Hello;
begin
writeln ('Hello, world.')
end.
$ fpc hello_world.pas
Free Pascal Compiler version 2.6.4 [2014/05/03] for i386 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for i386
Compiling hello_world.pas
Linking hello_world
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? 4 lines compiled, 0.3 sec
$ ./hello_world
Hello, world.

2) It does not work with my glut.pas code:
procedure glutInitPascal(ParseCmdLine: Boolean);
var
  Cmd: array of PChar;
  CmdCount, I: Integer;
begin
  if ParseCmdLine then
    CmdCount := ParamCount + 1
  else
    CmdCount := 1;
  SetLength(Cmd, CmdCount);
  for I := 0 to CmdCount - 1 do
    Cmd[I] := PChar(ParamStr(I));
  glutInit(@CmdCount, @Cmd);
end;
$ fpc glut.pas
Free Pascal Compiler version 2.6.4 [2014/05/03] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling glut.pas
glut.pas(12,15) Error: Illegal type conversion: "ShortString" to "PChar"
glut.pas(13,11) Error: Identifier not found "glutInit"
glut.pas(15) Fatal: Syntax error, "BEGIN" expected but "end of file" found
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

3) It does not work when I am compiling hedgewars-src-0.9.20: $ cmake . -DNOSERVER=1
$ make
[...]
[ 6%] Building Pascal object hedgewars/CMakeFiles/hwengine.dir/hwengine.o options.inc(25,3) Fatal: Can't find unit GL used by uConsts Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled) make[2]: *** [hedgewars/CMakeFiles/hwengine.dir/hwengine.o] Error 1 make[1]: *** [hedgewars/CMakeFiles/hwengine.dir/all] Error 2 make: *** [all] Error 2

It seems that my opengl unit is not found.
However, it seems to be installed because, as you can see, the files are here: usr/lib/fpc/2.6.4/units/i386-linux/opengl/
usr/lib/fpc/2.6.4/units/i386-linux/opengl/freeglut.ppu usr/lib/fpc/2.6.4/units/i386-linux/opengl/glext.o
usr/lib/fpc/2.6.4/units/i386-linux/opengl/glu.ppu
usr/lib/fpc/2.6.4/units/i386-linux/opengl/Package.fpc usr/lib/fpc/2.6.4/units/i386-linux/opengl/glx.o
usr/lib/fpc/2.6.4/units/i386-linux/opengl/glx.ppu
usr/lib/fpc/2.6.4/units/i386-linux/opengl/glu.o
usr/lib/fpc/2.6.4/units/i386-linux/opengl/freeglut.o usr/lib/fpc/2.6.4/units/i386-linux/opengl/glext.ppu usr/lib/fpc/2.6.4/units/i386-linux/opengl/glut.o
usr/lib/fpc/2.6.4/units/i386-linux/opengl/glut.ppu usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpfreeglut.a usr/lib/fpc/2.6.4/units/i386-linux/opengl/gl.ppu
usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpgl.a usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpglext.a usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpglu.a usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpglx.a usr/lib/fpc/2.6.4/units/i386-linux/opengl/gl.o
usr/lib/fpc/2.6.4/units/i386-linux/opengl/libpglut.a

Do you know why I am unable to compile 2) and 3)?

Thank you.
Best regards.

Reply by email

leledumbo
to YuGiOhJCJ Mailing-List
It does not work with my glut.pas code

Do you use {$mode objfpc} or {$mode delphi}? ParamStr should return AnsiString instead of ShortString there, and it's convertible to PChar. Otherwise, you can cast the result to AnsiString first.

P.S.: I don't recommend glut, not even freeglut, for learning OpenGL, use glfw instead for cross platform OpenGL toolkit.

It does not work when I am compiling hedgewars-src-0.9.20:

.nix filesystems are case sensitive. GL and gl is different. The compiler should've tried searching both though, so it must be something else. Check the generated Makefile, or better, the CMakeLists.txt.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/problem-with-the-opengl-unit-tp5719120p5719121.html Sent from the Free Pascal - General mailing list .

Reply by email

YuGiOhJCJ Mailing-List
to leledumbo

I don't know if I use {$mode objfpc} or {$mode delphi}. How to know it?

Strange that glut.pas is not correct because I have directly picked it from here: http://wiki.freepascal.org/OpenGL_Tutorial
Is it an old tutorial?

In CMakeLists.txt, nothing about GL:
$ find . -name "CMakeLists.txt" -exec grep "GL" '{}' \; set(QT_USE_QTOPENGL FALSE)
file(GLOB ServerSources ${CMAKE_SOURCE_DIR}/gameServer/*.hs) file(GLOB NetCpp net/*.cpp)
file(GLOB ModelCpp model/*.cpp)
file(GLOB_RECURSE UIcpp ui/*.cpp)
file(GLOB UtilCpp util/*.cpp)
file(GLOB ModelHdr model/*.h)
file(GLOB NetHdr net/*.h)
file(GLOB_RECURSE UIhdr ui/*.h)
file(GLOB UtilHdr util/*.h)
file(GLOB frontlib_src
find_package(GLUT REQUIRED)
find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built") file(GLOB DLLs *.dll)
file(GLOB ICOs *.ico)
file(GLOB txttrans2 ??.txt)
file(GLOB txttrans5 ?????.txt)
file(GLOB tsfiles *.ts)
file(GLOB luafiles *.lua)
file(GLOB missionfiles missions_*.txt)
file(GLOB campaignfiles campaigns_*.txt)
file(GLOB tipfiles tips_*.xml)
file(GLOB BaseMusic *.ogg)
file(GLOB txtnames *.txt)
file(GLOB cfgnames *.cfg)
file(GLOB Scripts *.lua)
file(GLOB Config *.ini)
file(GLOB Missions *.lua)
file(GLOB Packs *.hwp)
file(GLOB Config *.ini)
file(GLOB Missions *.lua)
file(GLOB Packs *.hwp)
file(GLOB Scripts *.lua)
file(GLOB luafiles *.lua)
file(GLOB luafiles *.lua)
file(GLOB cfgfiles *.cfg)
file(GLOB miscfiles *.xml *.desktop)
file(GLOB FlagTemplates *.png)
file(GLOB MissionPics )
file(GLOB AmmoMenuSprites *.png)
file(GLOB HedgehogSprites *.png)
file(GLOB GraveSprites *.png)
file(GLOB BaseSprites *.png)
file(GLOB Sprites *.png)
file(GLOB HatSprites *.png)
file(GLOB HatSprites *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB images *.png)
file(GLOB BaseSounds *.ogg)
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB VoiceSounds
file(GLOB FortSprites *L.png *R.png)

I am not looking for learning OpenGL, I just want a minimal example to be sure that my OpenGL unit is working correctly. Do you have something like that?

Show quoted text 23 lines
> It does not work with my glut.pas code Do you use {$mode objfpc} or {$mode delphi}? ParamStr should return AnsiString instead of ShortString there, and it's convertible to PChar. Otherwise, you can cast the result to AnsiString first. P.S.: I don't recommend glut, not even freeglut, for learning OpenGL, use glfw instead for cross platform OpenGL toolkit. > It does not work when I am compiling hedgewars-src-0.9.20: .nix filesystems are case sensitive. GL and gl is different. The compiler should've tried searching both though, so it must be something else. Check the generated Makefile, or better, the CMakeLists.txt. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/problem-with-the-opengl-unit-tp5719120p5719121.html Sent from the Free Pascal - General mailing list . _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

YuGiOhJCJ Mailing-List
to Reimar Grabowski

Indeed, I found an example in /usr/share/doc/fpc-2.6.4/opengl/examples/bounce.pp.

$ fpc bounce.pp
Free Pascal Compiler version 2.6.4 [2014/05/03] for i386 Copyright (c) 1993-2014 by Florian Klaempfl and others Target OS: Linux for i386
Compiling bounce.pp
bounce.pp(14,3) Fatal: Can't find unit gl used by bounce Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

So there is really a problem with my GL (or gl) unit. If this is only a problem of upper case, can you tell me how I can fix it?

This is the way I have compiled fpc-2.6.4 (it can be useful):
$ tar xvf fpc-2.6.4.i386-linux.tar
$ tar xvf fpcbuild-2.6.4.tar.gz
$ cd fpc-2.6.4.i386-linux
$ mkdir binary.i386-linux
$ cd -
$ cd fpc-2.6.4.i386-linux/binary.i386-linux
$ tar xvf ../binary.i386-linux.tar
$ for each in *.tar.gz; do tar xvf ${each}; done
$ cd -
$ cd fpc-2.6.4.i386-linux/binary.i386-linux/bin
$ ln -s ../lib/fpc/2.6.4/ppc386
$ cd -
$ export PATH="${PWD}/fpc-2.6.4.i386-linux/binary.i386-linux/bin:${PATH}"
$ cd fpcbuild-2.6.4
$ fpcmake -Tall
$ make build NOGDB=1
$ make NOGDB=1 PREFIX=/tmp/fpc-2.6.4/usr install
$ cd -
$ cd /tmp/fpc-2.6.4/usr/bin
$ ln -s ../lib/fpc/2.6.4/ppc386
$ cd -
$ rm -rfv fpc-2.6.4.i386-linux fpcbuild-2.6.4

Do you see why my opengl unit is not found?

Show quoted text 13 lines
On Sat, 3 May 2014 20:48:02 +0200 YuGiOhJCJ Mailing-List wrote: > I am not looking for learning OpenGL, I just want a minimal example to be sure that my OpenGL unit is working correctly. > Do you have something like that? There should be some in fpcsrcdir/packages/opengl/examples/. hih R. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

leledumbo
to YuGiOhJCJ Mailing-List
So there is really a problem with my GL (or gl) unit. If this is only a problem of upper case, can you tell me how I can fix it?

I think it's rather a unit path problem. Compile with -vt and grep -i "unit path"
Make sure it lists path to your opengl units. If it doesn't, then check your fpc.cfg. There should be -Fu line pointing to the opengl units directory. Note that -Fu supports wildcard, so if you don't alter the layout, a single line of -Fu ending with * should be enough since the default layout is: $(fpc)/$(fpcversion)/units/$(fpctarget)/<package name>.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/problem-with-the-opengl-unit-tp5719120p5719126.html Sent from the Free Pascal - General mailing list .

Reply by email

YuGiOhJCJ Mailing-List
to leledumbo

This is where fpc is searching:
$ fpc -vt bounce.pp | grep "unit path"
Using unit path: /usr/lib/fpc/2.6.4/units/i386-linux/rtl/ Using unit path: /usr/lib/fpc/2.6.4/

I am wondering if it is correct because that is what I have in this last directory: $ ls /usr/lib/fpc/2.6.4/
ide msg ppc386 samplecfg units

For the configuration file, I had no one with the compilation steps I have given you in a previous message. I need to add these steps to generate configuration files: [...]
/tmp/fpc-2.6.4/usr/lib/fpc/2.6.4/samplecfg /tmp/fpc-2.6.4/usr/lib/fpc/2.6.4 /tmp/fpc-2.6.4/etc/ sed -i -e "s:/tmp/fpc-2.6.4::g" /tmp/fpc-2.6.4/etc/fpc.cfg sed -i -e "s:/tmp/fpc-2.6.4::g" /tmp/fpc-2.6.4/usr/lib/fpc/2.6.4/ide/text/fp.cfg [...]

Now, in my /etc/fpc.cfg file, I can see the correct lines: $ cat /etc/fpc.cfg | grep "Fu"
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/ -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20 -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22 -Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*

It seems to be good, as there is the -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/* line.

Do you know why the unit path is "/usr/lib/fpc/2.6.4/" instead of "/usr/lib/fpc/2.6.4/units/"?

Show quoted text 19 lines
> So there is really a problem with my GL (or gl) unit. > If this is only a problem of upper case, can you tell me how I can fix it? I think it's rather a unit path problem. Compile with -vt and grep -i "unit path" Make sure it lists path to your opengl units. If it doesn't, then check your fpc.cfg. There should be -Fu line pointing to the opengl units directory. Note that -Fu supports wildcard, so if you don't alter the layout, a single line of -Fu ending with * should be enough since the default layout is: $(fpc)/$(fpcversion)/units/$(fpctarget)/<package name>. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/problem-with-the-opengl-unit-tp5719120p5719126.html Sent from the Free Pascal - General mailing list . _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

leledumbo
to YuGiOhJCJ Mailing-List
Do you know why the unit path is "/usr/lib/fpc/2.6.4/" instead of

"/usr/lib/fpc/2.6.4/units/"?

No, but I did have problems with that many -Fu lines, which is why I reduce to just two:

-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*

And it works flawlessly. You can try and test it again.

Just to be sure, try this:
fpc -vt whatever | grep "Reading options"
to ensure the compiler reads from /etc/fpc.cfg, not somewhere else.

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/problem-with-the-opengl-unit-tp5719120p5719129.html Sent from the Free Pascal - General mailing list .

Reply by email

Mattias Gaertner
to YuGiOhJCJ Mailing-List: This is where fpc is searching: $ fpc -vt bounce.pp | grep "unit path" Using unit path:…
This is where fpc is searching: $ fpc -vt bounce.pp | grep "unit path" Using unit path: /usr/lib/fpc/2.6.4/units/i386-linux/rtl/ Using unit path: /usr/lib/fpc/2.6.4/

These are the default unit paths of the compiler.
It normally means you have no /etc/fpc.cfg.
You wrote you have a /etc/fpc.cfg. Please post the whole output of "fpc -vt bounce.pp"

Mattias

Reply by email