Since you should compile your app with similar flags used to
build FLTK
(for consistency and library compatibility), fltk-config is
used to output
those flags used to last build fltk so you can use them in
your Makefile.
Generally the technique is to have your Makefile invoke
fltk-config
with various options to get at least these three things:
1) $(CXX) -- the name of the compiler (e.g. g++)
2) $(CXXFLAGS) -- the compiler flags
3) $(LDFLAGS) -- the linker flags
So a simple example:
CXX=$(shell fltk-config
--cxx)
CXXFLAGS=$(shell fltk-config
--cxxflags)
LDFLAGS=$(shell fltk-config
--use-images --ldstaticflags)
..and then you'd compile and link your app with these
simple Makefile targets:
# CREATE EXECUTABLE FROM OBJ
hello: hello.o
$(CXX) hello.o $(LDFLAGS) -o hello
# COMPILE .cpp -> .obj
hello.o: hello.cpp
$(CXX) $(CXXFLAGS) hello.cpp -c
..and together that makes a simple Makefile for an app called
'hello'.
Since fltk-config is usually not in the PATH, and there might
be several versions of
FLTK on your drive, it's best to use a specific path to the
fltk-config program,
so you'd use this instead to set those three variables:
# Path to a specific FLTK version's fltk-config script
FLTKCONFIG=/usr/local/src/fltk-1.4.x-git/fltk-config
CXX=$(shell $(FLTKCONFIG) --cxx)
CXXFLAGS=$(shell $(FLTKCONFIG) --cxxflags)
LDFLAGS=$(shell $(FLTKCONFIG) --use-images --ldstaticflags)
This works (I just tested it on my Ubuntu machine).
This is fine in a gnu make environment with a unixy compiler.
On windows if you build your app with mingw/msys, you should
be able to work similarly.
I can't remember if there's a technique to do this in Windows
with
Visual Studio / NMAKE. If I remember correctly, nmake doesn't
support
a way to invoke an external program and pass the output to a
variable
the way $(shell) can in gnu make.
However, a cmake build of FLTK might provide an NMAKE Makefile
that
you can use.. I think there's a README file in the fltk
directory that's
supposed to cover this.
Offhand I'd guess that you can invoke fltk-config to output to
small text files,
and then use perl/sed/awk/whatever to jiggle those files into
NMAKE syntax,
and then 'include' those files in your NMAKE to set those
variables..?
I could swear either Ian or Matt wrote an article on all this,
but I can't
find it, so I made the above instead.
I do see in the "FLTK Basics" section of the FLTK docs:
https://www.fltk.org/doc-1.4/basics.html
..there's a section that covers building your own Makefiles,
which is probably
similar to the above, but I think it also discusses the new
cmake stuff
which may help with NMAKE, not sure. cmake is still relatively
new to FLTK
in 1.4, and is the preferred way to build FLTK on all
platforms now (I think).
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/vj6Z_3KufEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/fe49eaa2-1ca5-cec5-e5fb-dc313f3cab7d%40seriss.com.
On 7/28/22 07:12, Daniel Silva wrote:
Thank you.
However --ldstaticflags returns the fltk installation to link with "/usr/local/lib/libfltk.a", and doesn't return all the fltk dependencies, so I got linking errors.--ldstaticflags returns "/usr/local/lib/libfltk.a -lXrender -lXft -lfontconfig -pthread -lpthread -lm -lX11"But the first definition of LDLIBS var in fltk-config is "LDLIBS=" -lm -lX11 -lXext -lpthread -lXinerama -lXfixes -lXcursor -lXft -lXrender -lm -lfontconfig -ldl"And works fine.
# /usr/local/src/fltk-1.4.x-git/fltk-config --ldstaticflags..which looks a lot like your correct flags.
/usr/local/src/fltk-1.4.x-git/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXft -lfontconfig -lXinerama -pthread -lpthread -ldl -lm -lX11
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/vj6Z_3KufEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/01c0f6b5-3526-9076-b3a2-f0d0c6c58990%40online.de.
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/vj6Z_3KufEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAGFM6dY6MVmwKMtPjytLak%3DWJvTvGp0j_E9q0A-xDsQ2_e8JUA%40mail.gmail.com.
On 7/28/22 07:37, Daniel Silva wrote:
However I'm not interested in the fltk lib --ldflags or --ldstaticflags returns,
because I'm linking manually to the static fltk lib to my fltk build,
It returns the static version of fltk's lib and the
system dependencies.
So just be sure to not specify libfltk.a in your
Makefile, and let --ldstaticflags
specify it for you.
#include <FL/Fl_Double_Window.H>Then create a Makefile, with an FLTKCONFIG line at the top that
int main() {
Fl_Double_Window win(200,200,"test");
win.show();
return Fl::run();
}
FLTKCONFIG=/path/to/your/other/project/fltk-1.4.x/fltk-config
CXX=$(shell $(FLTKCONFIG) --cxx)
CXXFLAGS=$(shell $(FLTKCONFIG) --cxxflags)
LDFLAGS=$(shell $(FLTKCONFIG) --ldstaticflags)
# CREATE EXECUTABLE FROM OBJ
hello: hello.o
$(CXX) hello.o $(LDFLAGS) -o hello
# COMPILE .cpp -> .obj
hello.o: hello.cpp
$(CXX) $(CXXFLAGS) hello.cpp -c
clean:
-/bin/rm hello.o hello
--
You received this message because you are subscribed to a topic in the Google Groups "fltk.general" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fltkgeneral/vj6Z_3KufEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/567a2ebb-d809-1e78-6c8e-deec2812f4de%40seriss.com.
On 10/31/22 20:04, anmol....@gmail.com wrote:
Hi Greg.I'm using this Makefile in Ubuntu on WSL2.I can use fltk-config to build a shared file e.g. fltk-config --compile hello.cxxHowever, for the static libs I get these errors. Any ideas?apt tells me that xinerama et all are installed
/usr/bin/ld: cannot find -lXrender
/usr/bin/ld: cannot find -lXcursor
/usr/bin/ld: cannot find -lXft
/usr/bin/ld: cannot find -lfontconfig
/usr/bin/ld: cannot find -lXinerama
I'm not familiar with WSL aspect of your setup, but with
ubuntu to build
e.g. fltk or fltk apps, you should make sure X development
libs are installed.
I can't remember if Ubuntu's apt system supports the "package
group" concept
that the redhat/yum does, and if there is a package group that
installs all that stuff
with a single group name. I think in my case on ubuntu, I did
an apt search for each
of those to see if there was a lib dev package, and just
installed them one by one
using 'apt install'.
Right now on my ubuntu 20 dev box, I'm seeing I installed
these libx11 dev
libs which is probably what you need:
..so for you to replicate that, I imagine it'd be:libx11-dev/focal-updates,focal-security,now 2:1.6.9-2ubuntu1.2 amd64 [installed]
libxcursor-dev/focal,now 1:1.2.0-2 amd64 [installed]
libxft-dev/focal,now 2.3.3-0ubuntu1 amd64 [installed]
libxft2/focal,now 2.3.3-0ubuntu1 amd64 [installed]
libxrender-dev/focal,now 1:0.9.10-1 amd64 [installed]
libxt-dev/focal,now 1:1.1.5-1 amd64 [installed]
sudo apt install libx11-dev libxcursor-dev libxft-dev libxft2 libxrender-dev libxt-dev