Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCL not recognizing C++14 #3562

Closed
Bradyk27 opened this issue Jan 16, 2020 · 9 comments · Fixed by #3567
Closed

PCL not recognizing C++14 #3562

Bradyk27 opened this issue Jan 16, 2020 · 9 comments · Fixed by #3567
Labels
Milestone

Comments

@Bradyk27
Copy link

Bradyk27 commented Jan 16, 2020

Your Environment

  • Operating System and version: Mac OSX 10.14.16
  • Compiler: Clang / GCC LLVM version 10.0.1 (clang-1001.0.46.4)
  • PCL Version: 1.3

Context

Trying to follow the introductory documentation by compiling the simple pcd_write.cpp example document. Have already installed pcl successfully (I believe)

Expected Behavior

Should compile with no errors

Current Behavior

error PCL requires C++14 or above
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Code to Reproduce

CPP File:

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int
  main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ> cloud;

  // Fill in the cloud data
  cloud.width    = 5;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);

  for (std::size_t i = 0; i < cloud.points.size (); ++i)
  {
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  }

  pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
  std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

  for (std::size_t i = 0; i < cloud.points.size (); ++i)
    std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

  return (0);
}

cmakelists:

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(MY_GRAND_PROJECT)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

make file:

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.16

# Default target executed when no arguments are given to make.
default_target: all

.PHONY : default_target

# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:


#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canonical targets will work.
.SUFFIXES:


# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list


# Suppress display of executed commands.
$(VERBOSE).SILENT:


# A target that is always out of date.
cmake_force:

.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /opt/local/bin/cmake

# The command to remove a file.
RM = /opt/local/bin/cmake -E remove -f

# Escaping for special characters.
EQUALS = =

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /Users/admin/desktop

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /Users/admin/desktop/build

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target rebuild_cache
rebuild_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
	/opt/local/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache

.PHONY : rebuild_cache/fast

# Special rule for the target edit_cache
edit_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
	/opt/local/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache

.PHONY : edit_cache/fast

# The main all target
all: cmake_check_build_system
	$(CMAKE_COMMAND) -E cmake_progress_start /Users/admin/desktop/build/CMakeFiles /Users/admin/desktop/build/CMakeFiles/progress.marks
	$(MAKE) -f CMakeFiles/Makefile2 all
	$(CMAKE_COMMAND) -E cmake_progress_start /Users/admin/desktop/build/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
	$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean

# The main clean target
clean/fast: clean

.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
	$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast

# clear depends
depend:
	$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

#=============================================================================
# Target rules for targets named pcd_write_test

# Build rule for target.
pcd_write_test: cmake_check_build_system
	$(MAKE) -f CMakeFiles/Makefile2 pcd_write_test
.PHONY : pcd_write_test

# fast build rule for target.
pcd_write_test/fast:
	$(MAKE) -f CMakeFiles/pcd_write_test.dir/build.make CMakeFiles/pcd_write_test.dir/build
.PHONY : pcd_write_test/fast

pcd_write.o: pcd_write.cpp.o

.PHONY : pcd_write.o

# target to build an object file
pcd_write.cpp.o:
	$(MAKE) -f CMakeFiles/pcd_write_test.dir/build.make CMakeFiles/pcd_write_test.dir/pcd_write.cpp.o
.PHONY : pcd_write.cpp.o

pcd_write.i: pcd_write.cpp.i

.PHONY : pcd_write.i

# target to preprocess a source file
pcd_write.cpp.i:
	$(MAKE) -f CMakeFiles/pcd_write_test.dir/build.make CMakeFiles/pcd_write_test.dir/pcd_write.cpp.i
.PHONY : pcd_write.cpp.i

pcd_write.s: pcd_write.cpp.s

.PHONY : pcd_write.s

# target to generate assembly for a file
pcd_write.cpp.s:
	$(MAKE) -f CMakeFiles/pcd_write_test.dir/build.make CMakeFiles/pcd_write_test.dir/pcd_write.cpp.s
.PHONY : pcd_write.cpp.s

# Help Target
help:
	@echo "The following are some of the valid targets for this Makefile:"
	@echo "... all (the default if no target is provided)"
	@echo "... clean"
	@echo "... depend"
	@echo "... rebuild_cache"
	@echo "... edit_cache"
	@echo "... pcd_write_test"
	@echo "... pcd_write.o"
	@echo "... pcd_write.i"
	@echo "... pcd_write.s"
.PHONY : help



#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
	$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
@Bradyk27
Copy link
Author

Sorry, I completely buggered up the formatting. first time submitting an issue

@taketwo
Copy link
Member

taketwo commented Jan 16, 2020

No problem, I've fixed the formatting.

Something weird is going on. Please post the output of $ make VERBOSE=1. Also, are you sure you have PCL 1.3? How did you obtain it?

@Bradyk27
Copy link
Author

Bradyk27 commented Jan 16, 2020

Macbook-Pro-2:build admin$ make VERBOSE=1
/opt/local/bin/cmake -S/Users/admin/desktop -B/Users/admin/desktop/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/local/bin/cmake -E cmake_progress_start /Users/admin/desktop/build/CMakeFiles /Users/admin/desktop/build/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/pcd_write.dir/build.make CMakeFiles/pcd_write.dir/depend
cd /Users/admin/desktop/build && /opt/local/bin/cmake -E cmake_depends "Unix Makefiles" /Users/admin/desktop /Users/admin/desktop /Users/admin/desktop/build /Users/admin/desktop/build /Users/admin/desktop/build/CMakeFiles/pcd_write.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/pcd_write.dir/build.make CMakeFiles/pcd_write.dir/build
[ 50%] Building CXX object CMakeFiles/pcd_write.dir/pcd_write.cpp.o
/Library/Developer/CommandLineTools/usr/bin/c++  -DDISABLE_LIBUSB_1_0 -DDISABLE_PCAP -DDISABLE_PNG -DDISABLE_VTK -Dqh_QHpointer -isystem /usr/local/include/pcl-1.9 -isystem /opt/local/include/eigen3 -isystem /opt/local/include  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk   -o CMakeFiles/pcd_write.dir/pcd_write.cpp.o -c /Users/admin/desktop/pcd_write.cpp
In file included from /Users/admin/desktop/pcd_write.cpp:2:
In file included from /usr/local/include/pcl-1.9/pcl/io/pcd_io.h:42:
In file included from /usr/local/include/pcl-1.9/pcl/pcl_macros.h:76:
/usr/local/include/pcl-1.9/pcl/pcl_config.h:7:4: error: PCL requires C++14 or
      above
  #error PCL requires C++14 or above
   ^
In file included from /Users/admin/desktop/pcd_write.cpp:2:
In file included from /usr/local/include/pcl-1.9/pcl/io/pcd_io.h:42:
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:80:9: error: using declaration
      requires a qualified name
  using uint8_t [[deprecated("use std::uint8_t instead of pcl::uint8_t")...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:80:16: error: expected ';' after
      using declaration
  using uint8_t [[deprecated("use std::uint8_t instead of pcl::uint8_t")...
               ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:81:9: error: using declaration
      requires a qualified name
  using int8_t [[deprecated("use std::int8_t instead of pcl::int8_t")]] ...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:81:15: error: expected ';' after
      using declaration
  using int8_t [[deprecated("use std::int8_t instead of pcl::int8_t")]] ...
              ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:82:9: error: using declaration
      requires a qualified name
  using uint16_t [[deprecated("use std::uint16_t instead of pcl::uint16_...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:82:17: error: expected ';' after
      using declaration
  using uint16_t [[deprecated("use std::uint16_t instead of pcl::uint16_...
                ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:83:9: error: using declaration
      requires a qualified name
  using int16_t [[deprecated("use std::uint16_t instead of pcl::int16_t"...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:83:16: error: expected ';' after
      using declaration
  using int16_t [[deprecated("use std::uint16_t instead of pcl::int16_t"...
               ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:84:9: error: using declaration
      requires a qualified name
  using uint32_t [[deprecated("use std::uint32_t instead of pcl::uint32_...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:84:17: error: expected ';' after
      using declaration
  using uint32_t [[deprecated("use std::uint32_t instead of pcl::uint32_...
                ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:85:9: error: using declaration
      requires a qualified name
  using int32_t [[deprecated("use std::int32_t instead of pcl::int32_t")...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:85:16: error: expected ';' after
      using declaration
  using int32_t [[deprecated("use std::int32_t instead of pcl::int32_t")...
               ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:86:9: error: using declaration
      requires a qualified name
  using uint64_t [[deprecated("use std::uint64_t instead of pcl::uint64_...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:86:17: error: expected ';' after
      using declaration
  using uint64_t [[deprecated("use std::uint64_t instead of pcl::uint64_...
                ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:87:9: error: using declaration
      requires a qualified name
  using int64_t [[deprecated("use std::int64_t instead of pcl::int64_t")...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:87:16: error: expected ';' after
      using declaration
  using int64_t [[deprecated("use std::int64_t instead of pcl::int64_t")...
               ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:88:9: error: using declaration
      requires a qualified name
  using int_fast16_t [[deprecated("use std::int_fast16_t instead of pcl:...
        ^
/usr/local/include/pcl-1.9/pcl/pcl_macros.h:88:21: error: expected ';' after
      using declaration
  using int_fast16_t [[deprecated("use std::int_fast16_t instead of pcl:...
                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/pcd_write.dir/pcd_write.cpp.o] Error 1
make[1]: *** [CMakeFiles/pcd_write.dir/all] Error 2
make: *** [all] Error 2
Macbook-Pro-2:build admin$ 

Cloned from Github then installed through Cmake and make.

@Bradyk27
Copy link
Author

I can also try on my Ubuntu machine to see if that produces a different result

@taketwo
Copy link
Member

taketwo commented Jan 16, 2020

The problem is that the compiler is called without -std=c++14 flag. Moving the lines:

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

to just below the project() line in CMakeLists might help.

@Bradyk27
Copy link
Author

As with all coding, the best solution is the simplest.

Works fine, much obliged.

@taketwo
Copy link
Member

taketwo commented Jan 16, 2020

The tutorial should work without these lines though. So seems like there is a problem on our side.

We do not set INTERFACE_COMPILE_FEATURES in this branch:

pcl/PCLConfig.cmake.in

Lines 646 to 652 in 655d8b0

else()
set_target_properties(${pcl_component}
PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${definitions}"
INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:${PCL_COMPILE_OPTIONS}>"
INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS};${PCL_CONF_INCLUDE_DIR}"
)
that's why your compiler did not get -std=c++14 flag automatically. This branch was added in #3341. @traversaro was there any particular reason why you skipped setting that property?

@taketwo taketwo added this to the pcl-1.10.0 milestone Jan 16, 2020
@traversaro
Copy link
Contributor

This branch was added in #3341. @traversaro was there any particular reason why you skipped setting that property?

I cannot remember or find any specific reason, I think it was just an error on my side because I initially developed the patch for PCL 1.9 (that did not propagated the INTERFACE_COMPILE_FEATURE) and then I ported it for PCL 1.10, but without checking if the other branches changed in the meanwhile, sorry for the trouble. If you like I can provide a fix.

@taketwo
Copy link
Member

taketwo commented Jan 17, 2020

Thanks for the quick response. Yes, a patch would very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants