Question

Probably similar questions are asked many times. However I couldn't solve my problem with any current answer. I hope to get a quick answer.

In QT C++, I'm trying to use Dime library which is from: https://bitbucket.org/Coin3D/dime/overview

I have a compiled .lib file of Dime library for windows. It's working with my friend's machine under Visual Studio. So I have all headers and dime.lib file.

In my .pro file, I do:

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = dimeTest
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui

LIBS += -L$$PWD/src/release/ -ldime
INCLUDEPATH += $$PWD/src
DEPENDPATH += $$PWD/src
PRE_TARGETDEPS += $$PWD/src/release/dime.lib
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include

$$PWD/include folder has all .h header files. $$PWD/src/release includes that lib file.

in my main.cpp, I just try to define a variable as DimeLine, but can't get it work. this is from a new qt project.

#include "mainwindow.h"
#include <QApplication>

#define DIME_NOT_DLL
#include <dime/entities/Line.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    dimeLine line; //please help!! :)

    return a.exec();
}

Error output:

undefined reference to `dimeLine::dimeLine()'
undefined reference to `vtable for dimeExtrusionEntity'
undefined reference to `dimeEntity::~dimeEntity()'
undefined reference to `vtable for dimeExtrusionEntity'
undefined reference to `dimeEntity::~dimeEntity()'
:-1: error: release/main.o: bad reloc address 0x13 in section `.eh_frame'
collect2.exe:-1: error: error: ld returned 1 exit status

Please help me to compile that, How can i use Dime Library in a QT project? I tried many ways to write a correct .pro file. Non of them worked. Always had same error messages as undefined reference to 'what i use'. I always do clean & qmake.

The current .pro file above is created with automatic way to click 'Add Library' option on the project.

I hope, an experienced guy can easily compile this.

All best!

UPDATE*1 I'm trying to re-compile Dime on my machine, may be problem is about trying to use that vs lib for qt, if anyone can help me also with compiling Dime : https://bitbucket.org/Coin3D/dime/overview on windows machine for QT Creator(uses mingw g++) I'll be sooo glad!!

Was it helpful?

Solution 2

I solved the problem by compiling the DIME library on my windows machine with msys. Here I'd like to share what steps I had, which mistakes: I hope it helps someone else.

-Firstly I had a .lib file from a friend, he was using Visual Studio however I observed that is not wokring with minwg g++ at all.

-So if you compile the library with Visual C++, then you get a .lib file. However when I compiled it with g++ with mingw on msys console, I got an .a file which is worked well with QT creator

-Also under ubuntu there is an already compiled version of that library libdime, the file is libdime.so, however don't try to get it run on windows :))

For Compiling Dime Library,

1-) Download all Source project from https://bitbucket.org/Coin3D/dime

2-) Install Mingw + msys, and be sure u added "C:\MinGW\bin" to your Path, because msys will need it, anyway then with msys console. CD to your dime folder.

3-) firstly need to configure it,

./configure --prefix=c:/yourDestinationForCompiledDIME

4-) you can check whether make can work correctly. Do not have any space on the dime folder where you are running those make, configure etc commands, otherwise it may fail.

make check

5-) make it

make

6-) now installing it,.

make install

Those are the steps for compiling Dime, now to add it to QT project

Now, Copy /lib/ and /include/ folders from c:/yourDestinationForCompiledDIME to your project folder. Lib folder should have .a libraries, and include has the header files. Those all you need to add a library to QT.

in .pro file:

win32: LIBS += -L$$PWD/lib/ -ldime

INCLUDEPATH += $$PWD/lib
DEPENDPATH += $$PWD/lib

win32-g++: PRE_TARGETDEPS += $$PWD/lib/libdime.a

INCLUDEPATH += $$PWD/include

in your cpp code, Important points are.

#define DIME_NOT_DLL 

and your header of course, whatever you need..

#include <dime/entities/Line.h>

All cpp code something like:

#include "mainwindow.h"
#include <QApplication>

#define DIME_NOT_DLL
#include <dime/entities/Line.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    dimeLine line; //please help!! :)

    return a.exec();
}

I hope it will be helpful to someone who need to sue Dime in QT project.

All best,..

OTHER TIPS

Well, after looking into the Dime sources, I noticed, that it requires using one of these two defines: DIME_DLL and DIME_NOT_DLL. I assume, that you are going to link to dime library statically, so, according to notes, you have to use DIME_NOT_DLL define. You can do that by adding the following line into your .pro file:

DEFINES += DIME_NOT_DLL
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top