pjueon / JetsonGPIO

A C++ library that enables the use of Jetson's GPIOs
MIT License
285 stars 102 forks source link

"When importing both JetsonGPIO.h and cuda_runtime.h at the same time, a compilation error occurs." #85

Closed CLMonster closed 1 year ago

CLMonster commented 1 year ago

Hello, Due to project needs, I encountered the following error during compilation when I simultaneously imported JetsonGPIO.h and cuda_runtime.h. The code is as follows.

#include <cuda_runtime.h>
#include <JetsonGPIO.h>

int main()
{
    return 0;
}
image

My Jetson info is as follows:

image

gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)

How can I solve this? Thank you very much!

pjueon commented 1 year ago

Sorry for the late reply. I tested your code on my jetson nano, and I could reproduced the issue. Interestingly, when I changed the source file to ".cpp", it compiles perfectly.

nvcc -o cuda_test cuda_test.cpp -lJetsonGPIO -lpthread

I assume that it's some nvcc's name mangling issue but I'm not sure. For now you can make some wrappers for JetsonGPIO in .cpp files and do not include the "JetsonGPIO.h" header file in your ".cu" files. Maybe this could solve the issue.

pjueon commented 1 year ago

Ah ha! I found it. This part of the TypeTraits.h was the problem.

I'll fix this soon.

pjueon commented 1 year ago

Ok, I've just merged the PR and I've confirmed that it fixed the issue. Closing the issue.

CLMonster commented 1 year ago

Ok, I've just merged the PR and I've confirmed that it fixed the issue. Closing the issue.

Thank you for helping me. I really appreciate it.