Generating executables on Ubuntu 18.04 Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 4:43 pm

Ubuntu 18.04 has a newer set of compilers than 16.04 and they catch errors which Visual Studio & OSX accepted.

But in trying to generate an executable (generated with no issues on Ubuntu 16.04 using DialogBlocks) I found that the native setup of Ubuntu 18.04 only produces 'Shared Library (Application/x-sharedLib)', whatever the setup of DialogBlocks.

I do not have enough knowledge of Ubuntu to tweak the system to produce executables à la 16.04.

Can anyone advise?

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Sun Jun 17, 2018 5:17 pm

Hi,

I've successfully created executables on ubuntu 18.04, both in a terminal and using CodeLite. If you find that using D::B always creates libs, that must be due to the D::B settings.

Are you sure you are editing the correct 'set' of settings and not an unused duplicate? Try introducing an intentional error e.g. an incorrect name for a dependent library, and see if it's noticed.

Regards,

David

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 5:32 pm

I created a simple project and the issue is identical. The make file is pasted below. Maybe that could help pinpoint the problem (and the solution°
Thanks.

### Begin DialogBlocks generated body
################################################################################
# Makefile generated by DialogBlocks
#
# Available configurations:
# release
################################################################################

CONFIG=release

# release
ifeq ($(CONFIG),release)
WXWIN=/home/raanan/wxWidgets
TOOLCHAINNAME=gtk2u
WXVERSION:=$(shell echo `$(WXWIN)/GCCBuildReleaseGTK2Unicode/wx-config --version`)
CXX=g++
LINKER=g++
CC=gcc
RESCOMP=windres.exe
RCFILEOBJ=Project1_rc.o
RCFILESRC=Project1.rc
RESOURCEOBJECT=
OUTPUTPATH=GCCRelease
OBJECTPATH=GCCRelease
BUILDPATHS=$(OBJECTPATH)
EXTRADEPENDENCIES=
PROGRAM=Project1
LIBS=$(shell $(WXWIN)/GCCBuildReleaseGTK2Unicode/wx-config --inplace --exec-prefix="$(WXWIN)/GCCBuildReleaseGTK2Unicode" --libs std --cxxflags)
LINKERFLAGS=
WARNINGFLAGS=-Wall -Wno-write-strings
OPTFLAGS=-O2
DEBUGFLAGS=
LIBPATH=
CPPINC:=$(shell $(WXWIN)/GCCBuildReleaseGTK2Unicode/wx-config --inplace --cxxflags)
GCCFLAGS=
LDFLAGS=$(LIBS) $(LIBPATH) $(LINKERFLAGS)
CPPFLAGS=$(CPPINC) $(GCCFLAGS) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNINGFLAGS)
LIBDIRNAME=$(WXWIN)/GCCBuildReleaseGTK2Unicode/lib
RESPATH=--include-dir "$(WXWIN)/include" --include-dir "$(WXWIN)/contrib/include" --include-dir "$(WXWIN)/GCCBuildReleaseGTK2Unicode/lib/wx/include/gtk2-unicode-static-3.1"
MACPACKAGEINFO=
endif

OBJECTS=$(OBJECTPATH)/project1app.o $(OBJECTPATH)/testframe.o $(RESOURCEOBJECT)

all: $(BUILDPATHS) $(MACPACKAGEINFO) $(OUTPUTPATH)/$(PROGRAM)

$(OBJECTPATH):
mkdir -p $(OBJECTPATH)

clean:
rm -f $(OBJECTPATH)/*.o
rm -f $(OBJECTPATH)/*.res
rm -fr .deps .pch
rm -fr $(PROGRAM).app
rm -f $(OUTPUTPATH)/$(PROGRAM)

help:
@echo "Usage: make -f Makefile CONFIG=[release] [all|clean|help]"

$(OUTPUTPATH)/$(PROGRAM): $(OBJECTS) $(EXTRADEPENDENCIES)
$(LINKER) -o [email protected] $(OBJECTS) $(LDFLAGS)


# Windows only
$(OBJECTPATH)/$(RCFILEOBJ): $(RCFILESRC)
$(RESCOMP) --use-temp-file -i$< [email protected] $(RESPATH) --include-dir . --define NOPCH

# Mac only
$(OUTPUTPATH)/$(PROGRAM).app/Contents/PkgInfo: $(OUTPUTPATH)/$(PROGRAM) $(INFOPLISTSOURCE) $(ICNSSOURCE)
mkdir -p $(OUTPUTPATH)/$(PROGRAM).app/Contents
mkdir -p $(OUTPUTPATH)/$(PROGRAM).app/Contents/MacOS
mkdir -p $(OUTPUTPATH)/$(PROGRAM).app/Contents/Resources
sed -e "s/IDENTIFIER/$(PROGRAM)/" \
-e "s/EXECUTABLE/$(PROGRAM)/" \
-e "s/VERSION/$(WXVERSION)/" \
$(INFOPLISTSOURCE) >$(OUTPUTPATH)/$(PROGRAM).app/Contents/Info.plist
echo -n "APPL????" >$(OUTPUTPATH)/$(PROGRAM).app/Contents/PkgInfo
ln -f $(OUTPUTPATH)/$(PROGRAM) $(OUTPUTPATH)/$(PROGRAM).app/Contents/MacOS/$(PROGRAM)
cp -f $(ICNSSOURCE) $(ICNSDEST)

$(OBJECTPATH)/project1app.o: project1app.cpp project1app.h testframe.h
$(CXX) -c -o [email protected] $(CPPFLAGS) project1app.cpp

$(OBJECTPATH)/testframe.o: testframe.cpp testframe.h
$(CXX) -c -o [email protected] $(CPPFLAGS) testframe.cpp

.PHONY: all clean
### End DialogBlocks generated body

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Sun Jun 17, 2018 6:26 pm

I don't use D::B so I can't compare it with anything here. However you could diff it against the corresponding 16.04 makefile; that might show something helpful.

I presume D::B has a pane that acts as a read-only terminal where the build output can be seen. If so it would be interesting to see that output too.

Also, what happens if you (backup your current project and) copy/paste the working 16.04 project into 18.04. Does building then work correctly?

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 6:46 pm

I started by copying a 16.04 project into 18.04, and that is where the problem arose.

I then created a simple D::B project whose make was pasted earlier.
Below is the output of the build, built with the wxWidget Trunk.

----------------------- Configuration: GCC Release -----------------------
In directory: /home/raanan/DBProjects/Test
make -f Makefile CONFIG=release clean all
rm -f GCCRelease/*.o
rm -f GCCRelease/*.res
rm -fr .deps .pch
rm -fr Project1.app
rm -f GCCRelease/Project1
g++ -c -o GCCRelease/project1app.o -I/home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/wx/include/gtk2-unicode-static-3.1 -I/home/raanan/wxWidgets/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -D__WXGTK__ -pthread -O2 -Wall -Wno-write-strings project1app.cpp
g++ -c -o GCCRelease/testframe.o -I/home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/wx/include/gtk2-unicode-static-3.1 -I/home/raanan/wxWidgets/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -D__WXGTK__ -pthread -O2 -Wall -Wno-write-strings testframe.cpp
*** testframe.cpp: In member function ‘void TestFrame::CreateControls()’:
*** testframe.cpp:113:16: warning: unused variable ‘itemFrame1’ [-Wunused-variable]
*** TestFrame* itemFrame1 = this;
*** ^~~~~~~~~~
g++ -o GCCRelease/Project1 GCCRelease/project1app.o GCCRelease/testframe.o -I/home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/wx/include/gtk2-unicode-static-3.1 -I/home/raanan/wxWidgets/include -D_FILE_OFFSET_BITS=64 -DwxDEBUG_LEVEL=0 -D__WXGTK__ -pthread -L/home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib -pthread /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_gtk2u_xrc-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_gtk2u_qa-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_baseu_net-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_gtk2u_html-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_gtk2u_adv-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_gtk2u_core-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_baseu_xml-3.1.a /home/raanan/wxWidgets/GCCBuildReleaseGTK2Unicode/lib/libwx_baseu-3.1.a -lgthread-2.0 -pthread -lX11 -lSM -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lwxtiff-3.1 -lwxjpeg-3.1 -lwxregexu-3.1 -lwxscintilla-3.1 -lexpat -lpng -lz -ldl -lm


Done.

0 errors, 1 warning

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Sun Jun 17, 2018 7:40 pm

It looks as if it's making an executable called 'Project1'. Does such a file exist in ./GCCRelease/ ? If so, what is the output of doing, in a terminal:
file /full/path/to/GCCRelease/Project1

Or (perhaps I'm asking the same question in a different way) what is the filepath and name that gives 'Shared Library (Application/x-sharedLib)'? And what happens if you try to run it in a terminal as though it were an executable?

Do you still have the 16.04 install? If so, could you paste the successful build output from that?

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 8:14 pm

Project1 is the output file, and its type is Shared Library (application/x-sharedlib)
That is exactly the problem.
It runs while under DialogBlocks, but not when DialogBlocks is closed.I have no idea how to run it in a terminal.
I will reinstall 16.04, but I am sure that the script executed under 18.04 is identical to the script in 16.04, since there was no adaptation whatsoever of DialogBlocks when installed on 18.04.
I suspect there are system-level parameters/paths which are different between 18.04 and 16.04.

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Sun Jun 17, 2018 8:28 pm

It runs while under DialogBlocks,
'Runs' as in works as an executable? If so, that strongly suggests that you don't have a problem. Instead, whatever you are using to get the Shared Library (application/x-sharedlib) type is giving the wrong answer.
I have no idea how to run it in a terminal.
Open a terminal (if you have a standard ubuntu install that's probably 'gnome terminal') and do:
/full/path/to/GCCRelease/Project1

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 8:55 pm

When I say the application executes from within DialogBlocks is that DialogBlocks executes it when the compilation terminates.

The file produced 'Project1' in the GCCRelease folder will not execute if clicked in its folder, and its icon is a Text icon and not the usual executable Square on its corner.

Project1 executes from a terminal, with an error message: Failed to load module "canberra-gtk-module'
Same goes for the other applications, they execute from the terminal like they do when the Executable icon is clicked (when an Executable exists). Same error message.

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Sun Jun 17, 2018 9:21 pm


raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Sun Jun 17, 2018 9:43 pm

That removed the error message, but the problem remains.
I built a 64 bits libraries and application, but no change.

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Mon Jun 18, 2018 9:38 am

I'm sorry, but I'm still not clear about what the current status is.
When I say the application executes from within DialogBlocks is that DialogBlocks executes it when the compilation terminates.
Does that mean: DialogBlocks executes it and the program runs, does what it is supposed to do?
Or DialogBlocks tries to executes it but it doesn't succeed, or doesn't work as it should?
That removed the error message, but the problem remains.
Similarly in a terminal: does the program fail with an error message, execute but not work 100%, or execute and work correctly?

raananb
Super wx Problem Solver
Super wx Problem Solver
Posts: 381
Joined: Fri Oct 27, 2006 4:35 pm
Location: Paris, France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by raananb » Mon Jun 18, 2018 11:37 am

The program works as expected when run from a terminal or when DialogBlocks compiles & runs it. But this is not the final product.

What I am looking for is an executable which can be launched with a click on its icon, and which consequently can be stored on a website and downloaded and run by potential users (Filezilla, for example).

(This is similar to the difference in OSX between 'myprog.app', which is launched when clicked, and 'myprog' which is stored in 'myprog.app/Contents/MacOS' and which must be launched in a terminal).

BTW I reinstalled 16.04, where the problem does not exist: DialogBlocks (identical to what was installed on 18.04) produces an executable which runs when clicked.

DavidHart
Site Admin
Site Admin
Posts: 3839
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Generating executables on Ubuntu 18.04

Post by DavidHart » Mon Jun 18, 2018 2:34 pm

What I am looking for is an executable which can be launched with a click on its icon, and which consequently can be stored on a website and downloaded and run by potential users (Filezilla, for example)
Ah, so it's neither a D::B issue nor indeed a wx one; it's more to do with your particular Desktop Environment and/or filezilla settings. Another quick google ('ubuntu filezilla file association') got https://askubuntu.com/questions/214023/ ... -filezilla as the first hit.

However afaik there is no way you can alter the settings of all your end-users (especially if your program is not yet installed, but is still to be downloaded). I'm not at all knowledgeable about this sort of thing, but might it be possible to give your program a file-extension that will by default be recognised as 'Download this with filezilla', just as a 'txt' extension will be opened by a text editor?

Anyway, a Ubuntu or general Linux forum would be far better places to ask about this.

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 428
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Generating executables on Ubuntu 18.04

Post by xaviou » Mon Jun 18, 2018 6:44 pm

Hi.

I had the same problem when I've switched to Debian 9 some months ago.

It seems related to this problem

I've solved it adding -no-pie to the link process.

Command line sample :

Code: Select all

g++ -o TestExe -no-pie main.cpp
Regards
Xav'
My wxWidgets stuff web page : [email protected]'s wxStuff

Post Reply