Tk/Tcl extensions: error while compile BLT - tcl

I am compile BLT under OS X 10.10.5, while I make after ./configure, some error occur here:
FDSM_lhn#Nirvana:~/Downloads/blt2.4z$ sudo make -I/opt/X11/include
Password:
(cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make all)
gcc -c -Wall -O6 -I. -I. bltAlloc.c
warning: optimization level '-O6' is not supported; using '-O3' instead
In file included from bltAlloc.c:1:
In file included from ./bltInt.h:80:
./bltNsUtil.h:50:20: error: conflicting types for 'Tcl_FindCommand'
EXTERN Tcl_Command Tcl_FindCommand _ANSI_ARGS_((Tcl_Interp *interp,
^
/usr/local/include/tclDecls.h:1486:20: note: previous declaration is here
EXTERN Tcl_Command Tcl_FindCommand(Tcl_Interp *interp, const char *name,
^
In file included from bltAlloc.c:1:
In file included from ./bltInt.h:80:
./bltNsUtil.h:67:23: error: conflicting types for 'Tcl_CreateNamespace'
EXTERN Tcl_Namespace *Tcl_CreateNamespace _ANSI_ARGS_((Tcl_Interp *interp,
^
/usr/local/include/tclDecls.h:1460:24: note: previous declaration is here
EXTERN Tcl_Namespace * Tcl_CreateNamespace(Tcl_Interp *interp,
^
In file included from bltAlloc.c:1:
In file included from ./bltInt.h:80:
./bltNsUtil.h:72:23: error: conflicting types for 'Tcl_FindNamespace'
EXTERN Tcl_Namespace *Tcl_FindNamespace _ANSI_ARGS_((Tcl_Interp *interp,
^
/usr/local/include/tclDecls.h:1482:24: note: previous declaration is here
EXTERN Tcl_Namespace * Tcl_FindNamespace(Tcl_Interp *interp,
^
In file included from bltAlloc.c:1:
In file included from ./bltInt.h:80:
./bltNsUtil.h:75:12: error: conflicting types for 'Tcl_Export'
EXTERN int Tcl_Export _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Namespace *nsPtr,
^
/usr/local/include/tclDecls.h:1469:13: note: previous declaration is here
EXTERN int Tcl_Export(Tcl_Interp *interp, Tcl_Namespace *nsPtr,
^
1 warning and 4 errors generated.
make[1]: *** [bltAlloc.o] Error 1
make: *** [all] Error 2
What should I do to avoid this?

You're working with an elderly codebase, so some surgery is required. Alas.
The four offending declarations in bltNsUtil.h need to be removed as Tcl now declares them properly; Tcl_FindCommand, Tcl_CreateNamespace, Tcl_FindNamespace and Tcl_Export are part of Tcl's public API and have been for years. (The problem declarations are on lines 50, 67, 72, and 75, plus probably one or two lines further in each case.)
Also, you're recommended to not use sudo while doing the build itself, but rather just when doing the install afterwards. Mere compilation of the code shouldn't require elevated permissions.

Related

Cython Extern C++ Function

I'm trying to extern a c++ function to cython. Here is my code (all files are in the same directory)
function.cpp
int cfunc(int x){
return x;
}
wrapper.pyx
cdef extern from "function.cpp":
cpdef int cfunc(int)
def pyfunc(int x):
return cfunc(x)
setup.py
from distutils.core import setup, Extension
from Cython.Build import cythonize
source = ['function.cpp', 'wrapper.pyx']
ext = [Extension('lib', source, language='c++')]
setup(ext_modules=cythonize(ext))
When I run python setup.py build_ext --inplace it gives the following error
/home/hyunix/anaconda3/envs/c-playground/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: build/temp.linux-x86_64-3.7/function.o: in function `cfunc(int)':
function.cpp:(.text._Z5cfunci+0x0): multiple definition of `cfunc(int)'; build/temp.linux-x86_64-3.7/wrapper.o:wrapper.cpp:(.text._Z5cfunci+0x0): first defined here
collect2: error: ld returned 1 exit status
error: command '/home/hyunix/anaconda3/envs/c-playground/bin/x86_64-conda_cos6-linux-gnu-c++' failed with exit status 1
However if I remove language='c++' from setup.py it works fine. Why does this happen?
I'm using:
Python 3.7.9
Cython 0.29.21
Ubuntu 20.04
Well, when you use cpdef int cfunc(int), you're explicitly creating a new C function, and a new python function. If you want to refer to cfunc() as it's externally defined in function.cpp, your signature should be
cdef extern from "function.cpp":
int cfunc(int)
So, when you compile with the language='c++' flag, Cython is giving you an appropriate error. However, when you remove the language flag, Cython needs to reason based on compiler directives whether you're asking for a .c or a .cpp, and it defaults to .c. You should notice that your wrapper is being compiled to .c instead of .cpp when the language argument is removed. In this C compilation, Cython does not recognize the signature in the .cpp, but it does recognize the cpdef. So, no error, but you're getting an empty cfunc function, as opposed to the one defined in cpp.

hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp:559:35: error: use of undeclared identifier 'QCOM'

I realize I need to define QCOM has the vendor somewhere, but which file / where is this typically declared?
I am getting the following exception while building the ROM for a lineageos project and need some help diagnosing and resolving the issue:
-MD -MF /home/lineageos/out/target/product/tb8504f/obj_arm/SHARED_LIBRARIES/libsdmcore_intermediates/drm/hw_info_drm.d -o /home/lineageos/out/target/product/tb8504f/obj_arm/SHARED_LIBRARIES/libsdmcore_intermediates/drm/hw_info_drm.o hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp"
hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp:559:35: error: use of undeclared identifier 'QCOM'
if (drm_format_modifier == (DRM_FORMAT_MOD_QCOM_COMPRESSED |
^
hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp:58:56: note: expanded from macro 'DRM_FORMAT_MOD_QCOM_COMPRESSED'
#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1)
^
hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp:560:11: error: use of undeclared identifier 'QCOM'
DRM_FORMAT_MOD_QCOM_DX | DRM_FORMAT_MOD_QCOM_TIGHT)) {
^
hardware/qcom/display-caf/msm8996/sdm/libs/core/drm/hw_info_drm.cpp:61:48: note: expanded from macro 'DRM_FORMAT_MOD_QCOM_DX'
#define DRM_FORMAT_MOD_QCOM_DX fourcc_mod_code(QCOM, 0x2)
^
Device tree:= https://github.com/darran-kelinske-fivestars/android_device_lenovo_tb8504f/tree/lineage-15.1
Vendor tree:= https://github.com/darran-kelinske-fivestars/android_vendor_lenovo_tb8504f/tree/lineage-15.1
Kernel source:= https://github.com/dazza5000/android_kernel_lenovo_msm8937/tree/tb8504f
ROM Source:= https://github.com/LineageOS/android
Command:
repo sync -j20 && source build/envsetup.sh && breakfast tb8504f && make -j20 | tee rom.log
Full log:
https://del.dog/ujizecehug
I don't know the long term fix for this issue, but my quick and dirty fix was to define the variable in both of the files that depend on it.
I went into the file hw_info_drm.cpp and added the following at the top:
#define QCOM 1

Error when installing Caffe on mac OS

Scanning dependencies of target caffeproto
[ 0%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o
In file included from /Users/cm/caffe/build/include/caffe/proto/caffe.pb.cc:4:
In file included from /Users/cm/caffe/build/include/caffe/proto/caffe.pb.h:25:
In file included from /usr/local/include/google/protobuf/generated_message_table_driven.h:34:
In file included from /usr/local/include/google/protobuf/map.h:49:
In file included from /usr/local/include/google/protobuf/map_type_handler.h:35:
In file included from /usr/local/include/google/protobuf/wire_format_lite_inl.h:43:
/usr/local/include/google/protobuf/message_lite.h:117:3: error: unknown type
name 'constexpr'
constexpr const T& get() const { return reinterpret_cast<const T&>(union_); }
^
/usr/local/include/google/protobuf/message_lite.h:117:13: error: expected member
name or ';' after declaration specifiers
constexpr const T& get() const { return reinterpret_cast<const T&>(union_); }
~~~~~~~~~ ^
I had the same issue. Here is what to do:
- if you are using cmake try to add -std=c++11 to C flags:
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
endif()
If you are using Make file, try to add the same flag to makefile
Hope this helps.
David

openACC pgc++ vs pgcc, error at linking

I downloaded the example from https://www.olcf.ornl.gov/tutorials/mixing-openacc-with-gpu-libraries/
The codes are given in the above mwntioned links
1) using pgcc
pgc++ -c cuFFT.cu
pgcc -acc -Mcudalib=cufft fft.c cufft.o
works perfectly fine
2) using pgc++
pgc++ -c cuFFT.cu
pgc++ -acc -Mcudalib=cufft fft.cpp (or .c samefiles) cufft.o
I get the following error
undefined reference to launchCUFFT(float*, int, void*)
pgacclnk: child process exit status 1: /usr/bin/ld
You're running into a C/C++ linking mismatch.
To get this to work in PGI 17.9 tools I had to:
rename cuFFT.cu to cuFFT.cpp
edit the malloc line in fft.c from:
float *data = malloc(2*n*sizeof(float));
to:
float *data = (float *)malloc(2*n*sizeof(float));
modify the declaration in fft.c from:
extern void launchCUFFT(float *d_data, int n, void *stream);
to:
extern "C" void launchCUFFT(float *d_data, int n, void *stream);
Issue the following compile commands:
$ pgc++ -c cuFFT.cpp
$ pgc++ -acc -Mcudalib=cufft fft.c cuFFT.o

Unable to decipher nvlink error

I'm attempting to build a project with nvcc. I am getting the most vexing nvlink error: messages I've ever seen.
Here is the link statement:
nvcc -rdc=true -arch=sm_21 -O3 -Xcompiler -fPIC -I"/usr/local/ACE_wrappers" -I"/usr/local/ACE_wrappers/TAO" -I"/usr/local/DDS" -I"/usr/include/Qt" -I"/usr/include/QtCore" -I"/usr/include/QtGui" -I"../../include" -I"../../include/DDS" -I"../../include/CoordinateTransforms" -I"../../include/DDS/IDLBrokerTemplates" -I"../../def/IDL" -I"../../def/CMD" -I"../../def/XSD" -I"../../src/NetAcquire" -I"/usr/local/ACE_wrappers/TAO/orbsvcs" -I"/usr/local/include/lct.7.5.4" -L"." -L"/usr/local/ACE_wrappers/lib" -L"/usr/local/DDS/lib" -L"/usr/lib64" -L"/usr/local/lib64" -L"../../def/IDL/lib" -L"../../def/XSD" -L"/usr/local/lib" .obj/../../src/Component.o .obj/../../src/COM.o .obj/../../src/DDS/EntityManager.o .obj/../../src/IDLBrokerTemplates/CommandManager.o .obj/../../src/IDLBrokerTemplates/OptionManager.o .obj/../../include/ApplicationProcessStateReporter_moc.o .obj/../../src/Application.o .obj/../../src/CoordinateTransforms/Site.o .obj/../../src/CoordinateTransforms/Geodesy.o .obj/../../src/CoordinateTransforms/Earth.o .obj/../../src/CoordinateTransforms/StateVector.o .obj/../../src/CoordinateTransforms/KeplerianImpact.o .obj/../../src/CoordinateTransforms/GeodeticPosition.o .obj/../../src/IDLBrokerTemplates/MeasurandSubscription.o .obj/../../src/NetAcquire/NetAcquire.o .obj/DataLossFlightTimeImpl.o .obj/DataLossFlightTime.o .obj/DftTable.o .obj/OptionListener.o .obj/PrimaryListener.o .obj/MissionTimeListener.o .obj/DeadMan.o .obj/main.o .obj/../../src/XML/spline.o .obj/../../src/XML/FpTable.o -l"naps-x86_64" -l"naio-x86_64" -l"nalct-x86_64" -l"curl" -l"TAO_Messaging" -l"TAO_Valuetype" -l"TAO_PI_Server" -l"TAO_PI" -l"TAO_CodecFactory" -l"TAO_CosNaming" -l"armadillo" -l"boost_filesystem" -l"boost_system" -l"xerces-c" -l"jarssXSD" -l"OpenDDS_Tcp" -l"JARSSRTv10" -l"QtNetwork" -l"fontconfig" -l"QtGui" -l"QtCore" -l"OpenDDS_Rtps_Udp" -l"OpenDDS_Rtps" -l"OpenDDS_Multicast" -l"OpenDDS_Udp" -l"OpenDDS_InfoRepoDiscovery" -l"OpenDDS_Dcps" -l"TAO_PortableServer" -l"TAO_AnyTypeCode" -l"TAO" -l"ACE" -o "DFT"
And I'm getting
nvlink error : Undefined reference to '_ZN5JARSS15KeplerianImpactC1ERKdS2_S2_S2_S2_S2_'
nvlink error : Undefined reference to '_ZNK5JARSS15KeplerianImpact9getStatusEv'
nvlink error : Undefined reference to '_ZNK5JARSS15KeplerianImpact13getImpactTimeEv'
nvlink error : Undefined reference to '_ZNK5JARSS15KeplerianImpact11getPlhStateEv'
nvlink error : Undefined reference to '_ZN5JARSS15KeplerianImpactD1Ev'
nvlink error : Undefined reference to '_ZN5JARSS7Geodesy12EFG2GeodeticERKdS2_S2_PdS3_S3_'
I'm certain that these functions/files are included in the compile. You can see from the compile that KeplerianImpact.cpp and Geodesy.cpp are in there.
Is there any way to make the link output easier to read so I can debug this?
Use c++filt to demangle the names. For instance:
$ c++filt _ZN5JARSS15KeplerianImpactC1ERKdS2_S2_S2_S2_S2_
JARSS::KeplerianImpact::KeplerianImpact(double const&, double const&, double const&, double const&, double const&, double const&)
Faced this problem earlier, I guess you haven't linked the device object using device linker.
Generate relocatable code for the device by compiling as shown below (-dc is the device equivalent of -c, see the manual for more information)
nvcc –arch=sm_21 –dc a.cu b.cu
Link the device parts of the code by calling nvlink or dlink before the final host link
nvlink -arch=sm_21 a.o b.o -o link.o (or)
nvcc –arch=sm_21 –dlink a.o b.o –o link.o
Finally form a executable using host compiler,
g++ a.o b.o link.o –L<path> -lcudart
I figured this out.
I needed to define my functions in the correct files. For example, in Foo.h:
class Foo {
public:
__host__ __device__
Foo();
}
and the function definition in Foo.cu not Foo.cpp as I originally thought.
Foo::Foo() {}
For the constant variables, I needed to implement a slightly different strategy.
Here is an example of the C++ class that I started with:
class Foo {
public:
static double const epsilon;
static void functionThatUsesEpsilon();
/**/
}
Had to be converted to use the global namespace as the epsilon def'n
namespace foo {
extern __constant__ double epsilon;
}
class Foo {
public:
// same stuff as before with the addition of this function
__host__ __device__
static inline double getEpsilon() {
#ifdef __CUDACC__
return foo::epsilon;
#else
return epsilon;
#endif
}
static void functionThatUsesEpsilon() {
if (bar < getEpsilon()) { // etc }
}
};
The ifdef above will return the correct version of the variable for either the host or the device code. Everywhere I had referenced Foo::epsilon I needed to replace with Foo::getEpsilon() so the correct epsilon was returned.
Hope this helps someone in the future. Thanks to #RobertCrovella for getting me thinking.