The PNG issue is one I've pointed out on the tigervnc-devel list before, but the TigerVNC developers have not accepted my fix for some reason. The patch to fix it is attached (0001-Link-vncviewer-with-libpng-this-avoids-a-build-error.patch).

As far as the FLTK build issues, I think that in your specific case, you can work around them by adding -DOPTION_USE_THREADS=0 to the CMake command line when building FLTK (NOTE: if so, then that should probably be documented in BUILDING.txt.)

I am attaching three more patches that I use when building FLTK with CMake. These may or may not be applicable to your environment (at least one is Mac-specific), but in the general case of building FLTK for multiple platforms, it is necessary to apply these patches in order to build FLTK "using the same procedures" that are used to build TigerVNC (as BUILDING.txt claims you should do.) Personally, I think these additional patches should be either pushed upstream to FLTK or provided with TigerVNC, but such has also never happened. I personally maintain my own GIT repository with a fully patched version of FLTK for use with TigerVNC.


On 10/30/13 2:33 PM, Dave Mackintosh wrote:
Greetings

For various reasons, I can’t install the RPMs for TigerVNC on my EL6
system.  So I am trying to build from source.

I have downloaded and installed cmake 2.8.12 from source.

I then downloaded and patched fltk 1.3.2.

The TigerVNC instructions say to use cmake to build fltk, however when I
do, the make phase ends like so:

[ 96%] Built target tabs

Linking CXX executable ../bin/examples/threads

CMakeFiles/threads.dir/threads.cxx.o: In function
`fl_create_thread(unsigned long&, void* (*)(void*), void*)':

threads.cxx:(.text+0x29): undefined reference to `pthread_create'

collect2: ld returned 1 exit status

make[2]: *** [bin/examples/threads] Error 1

make[1]: *** [test/CMakeFiles/threads.dir/all] Error 2

make: *** [all] Error 2

If I ignore the instructions and do a more traditional ./configure ;
make ; make install for fltk, it builds and installs.  However, the
vncviewer build then dies with

[100%] Building CXX object
vncviewer/CMakeFiles/vncviewer.dir/X11PixelBuffer.cxx.o

Linking CXX executable vncviewer

/usr/local/fltk/1.3.2-patched/lib/libfltk_images.a(Fl_PNG_Image.o): In
function `Fl_PNG_Image::load_png_(char const*, unsigned char const*, int)':

Fl_PNG_Image.cxx:(.text+0x71): undefined reference to
`png_create_read_struct'

Fl_PNG_Image.cxx:(.text+0x83): undefined reference to
`png_create_info_struct'

Fl_PNG_Image.cxx:(.text+0xaf): undefined reference to
`png_destroy_read_struct'

Fl_PNG_Image.cxx:(.text+0xe6): undefined reference to
`png_destroy_read_struct'

Fl_PNG_Image.cxx:(.text+0x147): undefined reference to `png_set_read_fn'

Fl_PNG_Image.cxx:(.text+0x158): undefined reference to `png_init_io'

Fl_PNG_Image.cxx:(.text+0x167): undefined reference to `png_read_info'

Fl_PNG_Image.cxx:(.text+0x176): undefined reference to `png_get_color_type'

Fl_PNG_Image.cxx:(.text+0x184): undefined reference to `png_set_expand'

Fl_PNG_Image.cxx:(.text+0x193): undefined reference to `png_get_color_type'

Fl_PNG_Image.cxx:(.text+0x1bc): undefined reference to `png_get_tRNS'

Fl_PNG_Image.cxx:(.text+0x1d1): undefined reference to `png_get_color_type'

Fl_PNG_Image.cxx:(.text+0x1ed): undefined reference to `png_get_image_width'

Fl_PNG_Image.cxx:(.text+0x204): undefined reference to
`png_get_image_height'

Fl_PNG_Image.cxx:(.text+0x21e): undefined reference to `png_get_bit_depth'

Fl_PNG_Image.cxx:(.text+0x22c): undefined reference to `png_set_packing'

Fl_PNG_Image.cxx:(.text+0x236): undefined reference to `png_set_expand'

Fl_PNG_Image.cxx:(.text+0x247): undefined reference to `png_get_bit_depth'

Fl_PNG_Image.cxx:(.text+0x255): undefined reference to `png_set_strip_16'

Fl_PNG_Image.cxx:(.text+0x269): undefined reference to `png_get_valid'

Fl_PNG_Image.cxx:(.text+0x278): undefined reference to
`png_set_tRNS_to_alpha'

Fl_PNG_Image.cxx:(.text+0x316): undefined reference to
`png_set_interlace_handling'

Fl_PNG_Image.cxx:(.text+0x334): undefined reference to `png_read_rows'

Fl_PNG_Image.cxx:(.text+0x354): undefined reference to `png_read_end'

Fl_PNG_Image.cxx:(.text+0x365): undefined reference to
`png_destroy_read_struct'

/usr/local/fltk/1.3.2-patched/lib/libfltk_images.a(Fl_PNG_Image.o): In
function `png_read_data_from_mem(png_struct_def*, unsigned char*,
unsigned long)':

Fl_PNG_Image.cxx:(.text+0x47d): undefined reference to `png_get_io_ptr'

Fl_PNG_Image.cxx:(.text+0x49e): undefined reference to `png_error'

collect2: ld returned 1 exit status

make[2]: *** [vncviewer/vncviewer] Error 1

make[1]: *** [vncviewer/CMakeFiles/vncviewer.dir/all] Error 2

make: *** [all] Error 2

I have libpng-devel installed.

Can anyone tell me what I am doing wrong?

--

David Mackintosh



------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk



_______________________________________________
Tigervnc-users mailing list
Tigervnc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-users

>From 7a15d1c9a908afe429c1aba1c27516d18bdea299 Mon Sep 17 00:00:00 2001
From: DRC <informat...@virtualgl.org>
Date: Tue, 26 Feb 2013 03:37:12 -0600
Subject: [PATCH 1/4] Add BUILD_STATIC feature from TigerVNC to (optionally)
 prevent FLTK from depending on libgcc and libstdc++

---
 CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1ee285..7d9d94b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,6 +150,49 @@ mark_as_advanced(LIB_CAIRO LIB_fontconfig LIB_freetype)
 mark_as_advanced(LIB_GL LIB_MesaGL)
 mark_as_advanced(LIB_jpeg LIB_png LIB_zlib)
 
+# This ensures that we don't depend on libstdc++ or libgcc
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT CYGWIN)
+  option(BUILD_STATIC
+    "Link statically against libgcc and libstdc++, if possible" OFF)
+  if(BUILD_STATIC)
+    # For some reason, simply passing ${CMAKE_CXX_FLAGS} to the compiler in
+    # execute_process() doesn't work.  Grrr...
+    if(CMAKE_SIZEOF_VOID_P MATCHES 8)
+      execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m64
+        --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
+        RESULT_VARIABLE RESULT)
+    else()
+      execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m32
+        --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
+        RESULT_VARIABLE RESULT)
+    endif()
+    string(REGEX REPLACE "\n" "" LIBSTDCPLUSPLUS ${LIBSTDCPLUSPLUS})
+    if(RESULT MATCHES 0 AND LIBSTDCPLUSPLUS)
+      message(STATUS "Linking with static libstdc++:\n   ${LIBSTDCPLUSPLUS}")
+      file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib)
+      execute_process(COMMAND ${CMAKE_COMMAND} -E remove
+        ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      if(MINGW)
+        execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+          ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      else()
+        execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+          ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+      endif()
+      set(CMAKE_EXE_LINKER_FLAGS
+        "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
+      set(CMAKE_SHARED_LINKER_FLAGS
+        "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
+    else()
+      message(WARNING Cannot find static libstdc++.  TigerVNC will depend on 
dynamic libstdc++.)
+    endif()
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+    set(CMAKE_SHARED_LINKER_FLAGS
+      "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
+  endif()
+endif()
+
 #######################################################################
 # functions
 include(CheckFunctionExists)
-- 
1.8.1.3

>From bf06cdf83375c11a47bddc3683143b3e2c0fdfcb Mon Sep 17 00:00:00 2001
From: DRC <informat...@virtualgl.org>
Date: Tue, 26 Feb 2013 03:38:45 -0600
Subject: [PATCH 2/4] Fl_cocoa.mm depends on some Carbon functions, so we need
 to include that framework.

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d9d94b..cae895e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,7 +51,7 @@ if(APPLE)
    set(HAVE_STRTOLL 1)
    set(HAVE_STRCASECMP 1)
    set(HAVE_DIRENT_H 1)
-   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
+   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa 
-framework Carbon")
 endif(APPLE)
 
 if(WIN32)
-- 
1.8.1.3

>From bb02d8426a9a279df76376313349c17774030753 Mon Sep 17 00:00:00 2001
From: DRC <informat...@virtualgl.org>
Date: Tue, 26 Feb 2013 04:01:36 -0600
Subject: [PATCH 3/4] We need to unset CMAKE_REQUIRED_LIBRARIES after checking
 for the libpng functions.  Otherwise, under certain circumstances (known to
 be an issue when building on OS X with the in-tree libpng implementation),
 the scandir() function check will fail, leaving HAVE_SCANDIR unset, and the
 build will subsequently fail.

---
 CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cae895e..0984aae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -210,6 +210,9 @@ if(LIB_png)
 endif(LIB_png)
 CHECK_FUNCTION_EXISTS(png_get_valid          HAVE_PNG_GET_VALID)
 CHECK_FUNCTION_EXISTS(png_set_tRNS_to_alpha  HAVE_PNG_SET_TRNS_TO_ALPHA)
+if(LIB_png)
+   set(CMAKE_REQUIRED_LIBRARIES "")
+endif(LIB_png)
 
 CHECK_FUNCTION_EXISTS(scandir                HAVE_SCANDIR)
 CHECK_FUNCTION_EXISTS(snprintf               HAVE_SNPRINTF)
-- 
1.8.1.3

>From df8586f39c0522b8e64cab2daf1e04823f0030c4 Mon Sep 17 00:00:00 2001
From: DRC <informat...@virtualgl.org>
Date: Fri, 1 Mar 2013 06:01:57 -0600
Subject: [PATCH 1/4] Link vncviewer with libpng (this avoids a build error
 when FLTK is built with a dynamic version of libpng
 instead of FLTK's in-tree version)

---
 CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4689566..e3475f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -265,6 +265,7 @@ if(UNIX AND NOT APPLE)
   if(X11_Xcursor_FOUND)
     set(FLTK_LIBRARIES ${FLTK_LIBRARIES} ${X11_Xcursor_LIB})
   endif()
+  set(FLTK_LIBRARIES ${FLTK_LIBRARIES} png)
 endif()
 
 if(FLTK_FOUND)
-- 
1.7.12.4 (Apple Git-37)

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Tigervnc-users mailing list
Tigervnc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-users

Reply via email to