0

I started experimenting with C/C++ the other day because I needed it for reading level-4 MAT-files without needing to purchase the Matlab editor or compiler. So I found just the library that I needed but I'm not familiar with C or C++ at all so I'm a beginner with those two languages. Anyhow I need to include the 'matio' library. I've tried many things but I've had no luck.

I right clicked on the C/C++ project > properties > C/C++ General > Paths & Symbols > GNU C and added the path to the matio library.

I also went to C/C++ Build > Settings > Tool settings > GCC C Compiler > Includes and added the path there aswell.

Since I'm not any good with makefiles yet I did not specify my own makefile, instead I chose a executable project.

When I try to build my project it complains about a function called 'Mat_Open' in the matio library. When I hover over it, it says "undefined reference to 'Mat_Open'" the header 'matio.h' seems to work fine but it can't refer to 'Mat_Open' for some reason.

How do I solve this?

EDIT:

Here is the whole build console output.

10:42:52 **** Incremental Build of configuration Debug for project Project ****
Info: Internal Builder is used for build
gcc -IC:/matio-1.5.2/src -O0 -g3 -Wall -c -fmessage-length=0 -o CComponent.o "..\\CComponent.c" 
gcc -Xlinker -lm -o Project.exe CComponent.o -lC:/matio-1.5.2/src 
c:/mingw(x64)/bin/../lib/gcc/x86_64-w64-mingw32/4.8.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lC:/matio-1.5.2/src
collect2.exe: error: ld returned 1 exit status

10:42:53 Build Finished (took 330ms)
4

1 回答 1

1

这不一定是答案,但可能对比较有用。

首先,你是在哪里安装的?如果您使用 Linux 或 Mac OSX,您将希望安装在系统目录中(不确定 Windows)。我在我的makefile中使用OSX(顺便说一下我使用 Qt):

LIBS += -L/usr/local/lib/ -lmatio
INCLUDEPATH += /usr/local/include

然后,当然,在我使用的源代码的 *.h 文件中:

#include "matio.h"

但我假设你已经尝试过了?

于 2014-01-06T23:33:21.930 回答