Author Topic: C::B trunk on MacOS: Commands between `backticks` do not work  (Read 6306 times)

Offline perazz

  • Multiple posting newcomer
  • *
  • Posts: 17
Hello,

Building a code that links against wxwidgets does not work on C::B (trunk) on MacOS because the commands between backticks are not returned.

They are the usual
Code
`wx-config --cxxlibs`
`wx-config --libs std,aui`

- If I run C::B from the Mac bundle from within the terminal:

Code
cd CodeBlocks.app/Contents/MacOS
./codeblocks

then everything works, e.g.:
Code
clang++ -Wall -g -std=c++11 -I/Users/federico/Downloads/wx/3.1.7/build-cocoa-debug/lib/wx/include/osx_cocoa-unicode-3.1 -I/Users/federico/Downloads/wx/3.1.7/include -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__  -c /Users/federico/....

If instead I open C::B by clicking on the package Icon, I get for the same file:
Code
clang++ -Wall -g -std=c++11  -c /Users/federico/.....

Notice there's a double space where the includes should be, so the call to wx-config is returning Codeblocks an empty string.

Anyone experienced that before? I think the Mac may be sending output to that command somewhere else which is not returned properly?

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 679
Re: C::B trunk on MacOS: Commands between `backticks` do not work
« Reply #1 on: July 19, 2022, 12:04:03 am »
Two things on backticks and building issues that I have seen are::
  • Watch what shell you have setup C::B to use for "Shell to run commands in:" via the settings->environment->general settings tab option. I found zsh has quirks compared to bash.
  • If you look at the following two files you will see how I have solved the issue of the wx-config and pkg-config:
As for the package icon difference if you use the full path to the wx-config and pkg-config then in my testing both ways of starting C::B works.

Offline perazz

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: C::B trunk on MacOS: Commands between `backticks` do not work
« Reply #2 on: July 19, 2022, 09:19:32 am »
I found that no Mac GUI app has access to the environment variables, they only apply to command-line shells
(see for example https://developer.apple.com/forums/thread/74371)

So, the standard way of calling wxwidgets flags via `wx-config --clibs` is never going to work on C::B on Mac if run from the packaged app.

I think the only way is to go back to use the global variable environment and define full-path commands like

Code
`$(#wx)/wx-config --cflags`

where $(#wx) is defined as the path-to-wx-config.
Unfortunately I see that wxwidgets GUI template projects do not use those wx global variables anymore, they've also switched
to using wx-config commands everywhere. I think this is never going to work on Mac apps.




Offline perazz

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: C::B trunk on MacOS: Commands between `backticks` do not work
« Reply #3 on: July 19, 2022, 12:42:22 pm »
   
  • If you look at the following two files you will see how I have solved the issue of the wx-config and pkg-config:

I see you've defined global variables for all commands. It seems like that's going to be the way to go. Older C::B versions had a
wizard to help you set them up for the local wx installation, but I notice that the new "wxWidgets GUI" project templates have instead
started to use `wx-config` calls with backticks, which is not a problem on unix or windows, but it is on MacOS, apparently.

Offline perazz

  • Multiple posting newcomer
  • *
  • Posts: 17
Re: C::B trunk on MacOS: Commands between `backticks` do not work
« Reply #4 on: July 19, 2022, 04:22:23 pm »
*** FIXED ***

my bad, I was exporting wxWidgets $PATH from the .zprofile file, which only applies to terminal shells.
Moving that to .zshenv has solved the issue.

For reference, see this discussion here: https://unix.stackexchange.com/questions/71253/what-should-shouldnt-go-in-zshenv-zshrc-zlogin-zprofile-zlogout

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 679
Re: C::B trunk on MacOS: Commands between `backticks` do not work
« Reply #5 on: July 27, 2022, 12:39:07 am »
Perazz,

If you have not seen it I have the DAP debugger plugin working on the MAC, which allows source level debugging on the MAC. For more info see the following thread
https://forums.codeblocks.org/index.php/topic,24930.msg170631/topicseen.html#msg170631