Author Topic: Trouble Complining CB with CB under Linux  (Read 3434 times)

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Trouble Complining CB with CB under Linux
« on: December 09, 2023, 07:25:54 pm »
I am trying to compoile the current trunk under Linux using CB.

In the updated SVN sources I found two workspaces for UNIX, both having 3.0 in the name and rigged for 3.0. I did not see any 3.2 versions.
Code
 CodeBlocks_wx30-unix.workspace
 ContribPlugins_wx30-unix.workspace

I opened the first one CodeBlocks_wx30-unix.workspace and tried to compile the "All" target. The wxWidgets version was a repository installed "3.0-dev", so it should fit with the project settings with "3.0".

I got only into the first prokect "Code::Blocks wx3.0.x - Unix" and got strange compile errors I had not seen anywhere before (see below).
It compiled the TinyXML files and before linking them I get this "/bin/sh syntax error". I did not find out where a batch file comes into this compile process.
Code
g++ -Wall -std=c++11 -fPIC (invalid) -fmessage-length=0 -fexceptions -Winvalid-pch -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -DcbDEBUG -DCB_PRECOMP -iquote.objs30/include -I.objs30/include -I. -Isdk/wxscintilla/include -Iinclude/tinyxml -Iinclude/tinyxml -c /home/%USER/data/codeblocks_svn/trunk/src/base/tinyxml/tinyxmlparser.cpp -o .objs30/base/tinyxml/tinyxmlparser.o
/bin/sh: 1: Syntax error: "(" unexpected
Process terminated with status 2 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Does someone have successfully compiled CB from another CB in Linux recently?

To rule out that this might be connected to the wx3.0 version, I downloaded and installed wx3.2.4, installed it as root in /usr/bin and installed CB from the downloaded sources using the standard autotools approach.
The gave me a running and working CB with this spec
Code
Name                   : Code::Blocks
Version                : svn-r13403
SDK Version            : 2.25.0
Scintilla Version      : 3.7.5
Author                 : The Code::Blocks Team
E-mail                 : info@codeblocks.org
Website                : https://www.codeblocks.org
OS                     : Linux 4.15.0-213-generic x86_64
Scaling factor         : 1,000000
Detected scaling factor: 1,000000
Display PPI            : 96x96
Display count          : 1
Display 0              : XY=[0,0]; Size=[1920,1080]; Primary

wxWidgets Library (wxGTK port)
Version 3.2.4 (Unicode: wchar_t, debug level: 1),
compiled at Dec  9 2023 18:26:36

Runtime version of toolkit used is 3.22.
Compile-time GTK+ version is 3.22.30.

Then I repeated the procedure with the newly and with the new "wx3.2" installed.
Result: the same errors.

Next I tried to set the project file to wx3.2 by changing the "build options/custom variables" to fit 3.2 as wxWidget version.
Same result.

So I am getting out of ideas. Any suggestions?

Thanks!

PS: The autotools would compile the trunk fine with wx3.0, but I got "undefined references" at runtime. The first I got was "UserVariableManager::ParseCommandLine" which in the sources I found in a libcodeblocks class. I did not see any unusual wxWidget code in there. I'd be interested to know the oldest compatible wxVersion to run CB (I do not care about optimizsations), because usually 3.2 is not part of the default repositories yet (e.g. the current UbuntuLTS 22.04 still ships with 3.0). I'd be much nicer w/o downloading and comiling wx manually. 

PPS: I checked the forum and wiki for info on Building CB with CB, The only section I found in the wiki was https://wiki.codeblocks.org/index.php/Installing_Code::Blocks#Working_on_Code::Blocks_sources_from_within_Code::Blocks.21. According to this it should work right out of the box.


« Last Edit: December 09, 2023, 07:28:00 pm by tigerbeard »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1600
Re: Trouble Complining CB with CB under Linux
« Reply #1 on: December 09, 2023, 08:10:13 pm »
Code
/bin/sh: 1: Syntax error: "(" unexpected
is due to the (invalid) parameter in the invocation of gcc:
Code
g++ -Wall -std=c++11 -fPIC (invalid) -fmessage-length=0...
Review the compiler settings to see where this come from.

EDIT: Parts of UserVariableManager were moved around by r13245, may be related.
« Last Edit: December 09, 2023, 08:24:20 pm by Miguel Gimenez »

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #2 on: December 09, 2023, 11:07:46 pm »
Thanks,I would not have seen that. Good to know next time I see a "/bin/sh" error.

The additional compiler flags showed that I did not set the GlobalVar
Code
$(#CB_RELEASE_TYPE)                   # cause of error. Was set by default to "(invalid)"
I found that I could not set it to "" but " " worked.

I changed the the custom variables to this
 
Code
 WX_VERSION = 32
 WX_CONFIG =/usr/local/bin/wx-config --version=3.2
The default settings did not compile, I got compiler/linker errors like "double declaration" and "undefined symbols".

Now I still have an undefined ref from AUI in the wxSmith plugin, but the basic code run. Hopefully the last obstacle is the dialog "Cannot find resources..."
Code
Code::Blocks was configured to be installed in '/home/user/data/codeblocks_svn/trunk/src/devel30/share/codeblocks'.
Please use the command-line switch '--prefix' or set the CODEBLOCKS_DATA_DIR environment variable to point where Code::Blocks is installed,

I tried both and keep getting the same dialog. Maybe again something stupid, but I am not getting it.

"/home/user/data/codeblocks_svn/trunk/src/devel30" has the codeblocks executable,
"/home/user/data/codeblocks_svn/trunk/src/devel30/share/codeblocks" only has the plugins SO's. 
Isn't then "/home/user/data/codeblocks_svn/trunk/src/devel30" the correct "point where Code::Blocks is installed"?

I tried to set "--prefix" and data dir but I keep getting the same Dialog and it would not start.

These are my start parameters
Code
 
  /start parameters
   -ns -ni -v -p  --prefix="/home/user/data/codeblocks_svn/trunk/src/devel30"

   CODEBLOCKS_DATA_DIR in Settings/GlobalVariables
    /home/user/data/codeblocks_svn/trunk/src/devel30
« Last Edit: December 09, 2023, 11:14:00 pm by tigerbeard »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7626
    • My Best Post
Re: Trouble Complining CB with CB under Linux
« Reply #3 on: December 09, 2023, 11:35:01 pm »
Did you run the correct "update" script to copy the resource and other files?

Edit2: likely update30 or update32

Tim S.
« Last Edit: December 10, 2023, 05:31:26 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: Trouble Complining CB with CB under Linux
« Reply #4 on: December 09, 2023, 11:46:11 pm »
maybe this is your case? As example on attached screenshot

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #5 on: December 10, 2023, 12:51:39 pm »
maybe this is your case? As example on attached screenshot
Yes, an image is better than 1000 words. Well done.

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #6 on: December 10, 2023, 01:01:31 pm »
Edit2: likely update30 or update32
indeed, I think I missed that.

=>YES. that solved both the nagging dialog and also the last compile error.
THX!


And attached it finally there is: CB running CB

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1600
Re: Trouble Complining CB with CB under Linux
« Reply #7 on: December 10, 2023, 04:02:54 pm »
If you plan to debug C::B you must define CB_RELEASE_TYPE = "-g" before compiling it, so the debug symbols are preserved.

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #8 on: December 11, 2023, 12:45:16 pm »
If you plan to debug C::B you must define CB_RELEASE_TYPE = "-g" before compiling it, so the debug symbols are preserved.
yeah, thanks I thought thats the right way since there is no All-debug target.

indeed, the inital movitation was to confirm your recent fix. Meanwhile I found I made a mistake above. Although CB did compile with 3.2 and started,  most of the contributes were missing. To get the working I would have to manually change each sub project to 3.2. So I reckon it it really should compile with wx3.0. So currently I am back at the undefined refs (e.g. wxControl::SetFont()) trying to figure out the problem.

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #9 on: December 11, 2023, 01:03:26 pm »
undefined refs (e.g. wxControl::SetFont()) trying to figure out the problem.

I think this is  the problem. The GTK2 lib only has a symbol for
Code
wxControlBase::SetFont
.
Code
// in src/gtk/control.cpp
#ifdef __WXGTK3__
bool wxControl::SetFont(const wxFont& font)
{

As the repostory wx-confilg resolves to -lwx_gtk2u_core-3.0 it seems that CB is incompatible to wxGKT2 versions. Currently I am compiling on an 18.04LTS system. The current 22.04 LTS repository has the GTK3 version, so hopefully that resolves it.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1600
Re: Trouble Complining CB with CB under Linux
« Reply #10 on: December 11, 2023, 01:19:19 pm »
Probably it is time to create the CodeBlocks_wx32-unix.workspace  :)

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #11 on: December 11, 2023, 05:13:24 pm »
Probably it is time to create the CodeBlocks_wx32-unix.workspace  :)

Maybe there is a wx-config that could be handled at the same time...(?)

Because I still can't get it compiled from CB. At least I know why: CB is still using the GKT2 system version in "/usr/bin/wx-config". I just did not yet find out how to make CB using the other one.

My PATH has "/usr/local/bin" with the correct wx-config to use.  When I open any terminal I get the correct version. I also tried to start CB from a terminal, but it keeps resolving it to "/usr/bin/wx-config".
Obviously I could re-edit each project and put the full full path the CustomVar page, but that can't be the standard approach, is it? Also changing the system default symlink each time I want to compile C::B seems wrong as well. There must be sth I am not seeing..

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7626
    • My Best Post
Re: Trouble Complining CB with CB under Linux
« Reply #12 on: December 12, 2023, 04:47:56 am »


I changed the the custom variables to this
 
Code
 WX_VERSION = 32
 WX_CONFIG =/usr/local/bin/wx-config --version=3.2

You told it to do what it is doing!!!
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #13 on: December 12, 2023, 10:47:19 am »
Code
 WX_VERSION = 32
 WX_CONFIG =/usr/local/bin/wx-config --version=3.2
You told it to do what it is doing!!!

well, not quite.
I had been reverting the values to default and use a gtk3 compiled version of wx3.0. I think that should fix the compile errors. But its still using the gtk2 version and not the gtk3 version.
Currently the build options are this:
 
Code
 
 // custom vars
 WX_VERSION = 30
 WX_CONFIG =wx-config --version=3.0
 //compiler
  `$(WX_CONFIG) --cflags`               # thats the default that resolves the compile options for wx
With the setting above its not clear to me how to use multiple wx-config on the system? I thought its using the same wx-config that I is default with my user by setting $PATH. This version that any terminal would use. Currently I have those two wx-configs on the system and the path is such that it should find the local one first which works fine in a terminal window.
 
Code
 
 /usr/bin/wx-config                    # CB is using that
 /usr/local/bin/wx-config              # all terminal windows use this
 echo $PATH
   .../usr/local/bin;/usr/bin...
From the terminal I can see what the two versions do. In the C::B build log I can see C::B is using the gkt2 version.
 
Code
 
   /usr/bin/wx-config --cflags            resolves to    -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 ....
   /usr/local/bin/wx-config --cflags      resolves to    -I/usr/local/lib/wx/include/gtk3-unicode-3.0 ....

I'd like to understand why C:B is using the first one.

Offline tigerbeard

  • Almost regular
  • **
  • Posts: 194
Re: Trouble Complining CB with CB under Linux
« Reply #14 on: December 15, 2023, 11:14:22 pm »
Update:
I finally got it compiled with wx3.0 GTK3.

I discoverd the tool Project options manipulator which allows to replace a variable in all projects of a workspace

So I replaced
Code
  WX_CONFIG     wx-config --version=$(WX_VERSION)  
  WX_CONFIG     /usr/local/bin/wx-config --version=$(WX_VERSION)
After that the whole workspace compiled fine and codeblocks starts from within codeblocks, now using the custom compiled wx3.0 GKT3 version.

I still do not understand why C::B ignores my $PATH setting. OF if there are other ways to solve that issue