我正在尝试编写一个既可以从NI USB DAQ获取数据又可以通过PortAudio播放音频的C / C++程序。问题是,看来Mac / Linux的NI DAQ库DAQmxBase必须在i386下构建,而我只是无法让PortAudio为i386构建。
我曾尝试在运行-arch=i386
之前将CFLAGS和LDFLAGS设置为./configure --disable-mac-universal && make && make install
,但是当我向PortAudio添加调用时,NI DAQmxBase示例代码仍然无法生成:
gcc -I../../includes -g -O2 -arch i386 acAnalogTest.c -framework nidaqmxbase -framework nidaqmxbaselv -o acAnalogTest
Undefined symbols for architecture i386:
"_Pa_Initialize", referenced from:
_main in ccf1t0bz.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make: *** [acAnalogTest] Error 1
NI DAQmxBase Makefile如下所示:
nilibs=-framework nidaqmxbase -framework nidaqmxbaselv
includes=-I../../includes
flags= -g -O2 -arch i386
cc=gcc
ao_examples = acAnalogTest acquireNScans
......
all : $(ao_examples)
% : %.c
>---$(cc) $(includes) $(flags) $< $(nilibs) -o $@
clean :
>---rm -f $(ao_examples)
更改DAQmxBase Makefile中的-arch标志无效:
gcc -I../../includes -g -O2 -arch x86_64 acAnalogTest.c -framework nidaqmxbase -framework nidaqmxbaselv -o acAnalogTest
In file included from acAnalogTest.c:1:
../../includes/NIDAQmxBase.h:104: warning: division by zero
../../includes/NIDAQmxBase.h:104: error: enumerator value for ‘assert_line_104’ is not an integer constant
../../includes/NIDAQmxBase.h:105: warning: division by zero
../../includes/NIDAQmxBase.h:105: error: enumerator value for ‘assert_line_105’ is not an integer constant
make: *** [acAnalogTest] Error 1
我认为这是因为DAQmxBase是在考虑i386数据类型的情况下编写的。上面来自NIDAQmxBase.h的错误引用的行是:
NIStaticAssert(sizeof(long) == 4, "Error: This platform is unsupported because long is not 4 bytes.");
NIStaticAssert(sizeof(int) == sizeof(long), "Error: This platform is unsupported because int is not the same size as long.");
我可以自行构建一些普通的PortAudio示例,但我想将PortAudio和DAQmxBase放在同一程序中,并让它们相处融洽。必须有一种构建PortAudio的方法,使其可以与DAQmxBase一起使用,不是吗?
谢谢!
最佳答案
DAQmx Base版本14.0和15.0支持64位应用程序,因此您现在应该能够升级驱动程序并重试。
DAQmx Base 15.0 for Mac
关于c++ - 无法为i386构建PortAudio以使其与NI的DAQmxBase兼容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21489514/