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

Add necessary boost headers to pcl/io to build in CUDA mode #2025

Merged
merged 4 commits into from
Oct 18, 2017
Merged

Add necessary boost headers to pcl/io to build in CUDA mode #2025

merged 4 commits into from
Oct 18, 2017

Conversation

bowang
Copy link
Contributor

@bowang bowang commented Oct 14, 2017

Currently all boost headers are disabled in pcl/io/boost.h when building in CUDA mode. However, boost is used in file_io.h and pcd_io.h. This PR adds the boost headers to make sure they can build when CUDA is enabled.

@SergioRAgostinho
Copy link
Member

What exactly is the compilation error you're getting by not including these?

@denix56
Copy link
Contributor

denix56 commented Oct 14, 2017

1>------ Build started: Project: pcl_io, Configuration: Release x64 ------
1>pcd_io.cpp
1>D:\dev-tools\pcl\io\src\pcd_io.cpp(770): error C2065: 'ssize_t': undeclared identifier
1>D:\dev-tools\pcl\io\src\pcd_io.cpp(770): error C2146: syntax error: missing ';' before identifier 'num_read'
1>D:\dev-tools\pcl\io\src\pcd_io.cpp(770): error C2065: 'num_read': undeclared identifier
1>D:\dev-tools\pcl\io\src\pcd_io.cpp(771): error C2065: 'num_read': undeclared identifier
1>Done building project "pcl_io.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

@bowang
Copy link
Contributor Author

bowang commented Oct 14, 2017

pcl/io/include/pcl/io/file_io.h(346): error: namespace "boost" has no member "iequals"
pcl/io/include/pcl/io/file_io.h(372): error: namespace "boost" has no member "iequals"
pcl/io/include/pcl/io/pcd_io.h(584): error: name followed by "::" must be a class or namespace name
pcl/io/include/pcl/io/pcd_io.h(592): error: name followed by "::" must be a class or namespace name

@SergioRAgostinho
Copy link
Member

So the problem between Boost and CUDA seem to be related to this https://stackoverflow.com/questions/7399688/cuda-with-boost . Nevertheless, recent boost versions started to take into account CUDA and NVCC.

The solution you propose is a workaround which might work only for your particular development environment, but we'll need other users to report problems to fully know. Nevertheless your include lines must be added to pcl/io/boost.h outside the __CUDACC__ ifdef guard to be consistent. Don't forget the QT as well.

@bowang
Copy link
Contributor Author

bowang commented Oct 14, 2017

Thanks for the feedback, Sergio. I moved the headers into pcl/io/boost.h. Please let me know of any other suggestions.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can save some if guards by doing the following: the current header file structure is something like this

#ifndef __CUDACC__
    #ifndef Q_MOC_RUN
        [...]
        <the headers you need came from this level>
        [...]
        #if BOOST_VERSION >= 104700
            [...]
        #endif
        [...]
        #if BOOST_VERSION >= 104900
            [...]
        #endif
    #endif /* Q_MOC_RUN */
#endif /* __CUDACC__*/

In order to reduce the number of if guards and account for your changes, you need to interchange Q_MOC_RUN and __CUDACC__ indentation levels, like this

#ifndef Q_MOC_RUN
    #ifndef __CUDACC__
        [...]
        <the headers you need came from this level ... (see below)>
        [...]
        #if BOOST_VERSION >= 104700
            [...]
        #endif
        [...]
        #if BOOST_VERSION >= 104900
            [...]
        #endif
    #else /* __CUDACC__*/
        <(cont.) ... and they are placed at this level>
    #endif /* __CUDACC__*/
#endif /* Q_MOC_RUN */

Please delete also lines 67 and 69. They're useless.

@@ -83,5 +82,9 @@
#include <boost/signals2/slot.hpp>
#endif
#endif
#ifndef Q_MOC_RUN
#include <boost/algorithm/string.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to erase the copy of this in line 66.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@bowang
Copy link
Contributor Author

bowang commented Oct 15, 2017

Thanks for the detailed instruction. Just updated accordingly. I also added indentation and comments on #ifndef #endif macros to improve readability.

@SergioRAgostinho
Copy link
Member

So... I appreciate the intention 😅 but we have this policy of not changing the indentation of the code, unless your changes actually affect those lines. We do this to make sure that our git blame is not "polluted" with authors which were not responsible for those lines. Therefore I need to ask only change what is really necessary.

One again my apologies.

@bowang
Copy link
Contributor Author

bowang commented Oct 16, 2017

No problem. Just removed the indentation and keep changes to minimum.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Comment to maintainers: squash commits

@taketwo taketwo merged commit ec56da9 into PointCloudLibrary:master Oct 18, 2017
@bowang bowang deleted the add_boost_header_to_pcl_io branch October 18, 2017 08:59
UnaNancyOwen pushed a commit to UnaNancyOwen/pcl that referenced this pull request Nov 24, 2017
…udLibrary#2025)

Restructure io/include/pcl/io/boost.h to fix compilation in CUDA mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants