Hola, tengo un código escrito en c++ y me compila bien en msvc++ y en codeblocks (mingw), sin embargo a la hora de correr un programa usando la librería generada, sólo la librería de codeblocks funciona, la de msvc++ no exporta a bennu la función. ¿Alguna sugerencia?
#ifndef __modProyectos
#define __modProyectos
#include <QApplication>
#include <QLabel>
#include <stdlib.h>
#include <stdio.h>
int ventana(){
int argv=0;
//QApplication app(argv,(char **)0);
//QLabel *label = new QLabel("Hello Qt!");
//label->show();
//return app.exec();
printf("buu");
}
//extern "C" int ventana();
/* Header file foo.h */
extern "C" {
#include <math.h>
#include "bgddl.h"
#include "bgdrtm.h"
#include "xstrings.h"
static int modEjecuta(INSTANCE * my, int * params)
{
ventana();
return 0;
}
HOOK __bgdexport (mod_proyectos , handler_hooks ) [] =
{
// { 4700 , updatePhisc},
{ 0 , NULL }
};
void __bgdexport( mod_proyectos, module_initialize )()
{
printf("bye");
}
void __bgdexport( mod_proyectos, module_finalize )()
{
printf("bye");
}
char * __bgdexport( mod_proyectos, modules_dependency )[] =
{
"libgrbase",
NULL
};
#define BENNU_export(a,b,c,d) {a,b,c,(void*)d}
DLSYSFUNCS __bgdexport( mod_proyectos, functions_exports) [] =
{
BENNU_export("EJECUTA" , "", TYPE_INT, modEjecuta),
{0, 0, 0, 0}
};
}
#endif
import "mod_proyectos"
begin
say(EJECUTA());
/* set_mode(400,300);
while (not (key(_esc)))
frame;
end*/
end
Gracias
cero experiencia.
en el bennupack hay 2 libreria dll que usa llamadas desde MVC++
Dll\VoiceCommands
Dll\bennuvideo
La verdad es que ni idea pero si lo consigues indica por favor los pasos para que queden por escrito.
Hola. No pude hacerlo desde visual. Link, vi las librerías (también tinixml) pero no supe cómo ni por qué no funcionaba.
Al final terminé recompilando qt para mingw32. Comparto el código.
Es un prototipo para un simulador, la idea es tener la gui en QT y la graficación en 3D en bennu usando bennu3d. Haremos un robot scara.
import "mod_proyectos"
begin
set_mode(800,600,32);
graphs();
while (not (key(_esc)))
frame;
if (key(_a))
say(GET_CADENA());
end
end
let_me_alone();
end
process graphs()
begin
graph=new_map(20,20,32);
map_clear(file,graph,0ffffff00h);
loop
x=400+get_distx(angle,150);
y=300+get_disty(angle,110);
angle+=3000;
frame;
end
onexit;
unload_map(file,graph);
end
Main.cpp
#ifndef __modProyectos
#define __modProyectos
#include <QApplication>
#include <QLabel>
#include <stdlib.h>
#include <stdio.h>
#include "Thread.h"
#include <math.h>
#include "bgddl.h"
#include "bgdrtm.h"
#include <iostream>
extern "C" __declspec(dllimport) int string_new(char const *);
using namespace std;
Thread * hilo;
int ventana(){
hilo =new Thread();
hilo->inicia();
}
void eliminaVentana(){
hilo->salir();
while(!hilo->isFinished());
delete hilo;
}
int tomaTexto(){
QString qs=hilo->v->textEdit->toPlainText();
string ss=qs.toStdString() ;
return string_new((const char *)ss.c_str());
}
extern "C" {
static int modEjecuta(INSTANCE * my, int * params)
{
printf("se ejecuta"); fflush(stdout);
return string_new("hola");
}
static int modGetCadena(INSTANCE * my, int * params)
{
return tomaTexto();
}
static int modEnd(INSTANCE * my, int * params)
{
eliminaVentana();
return 0;
}
HOOK __bgdexport (mod_proyectos , handler_hooks ) [] =
{
//{ 4700 , updatePhisc},
{ 0 , NULL }
};
void __bgdexport( mod_proyectos, module_initialize )()
{
ventana();
}
void __bgdexport( mod_proyectos, module_finalize )()
{
eliminaVentana();
}
char * __bgdexport( mod_proyectos, modules_dependency )[] =
{
"libgrbase",
NULL
};
#define BENNU_export(a,b,c,d) {a,b,c,(void*)d}
DLSYSFUNCS __bgdexport( mod_proyectos, functions_exports) [] =
{
BENNU_export("EJECUTA" , "", TYPE_STRING, modEjecuta),
BENNU_export("GET_CADENA" , "", TYPE_STRING, modGetCadena),
{0, 0, 0, 0}
};
}
#endif
Tread.cpp
#include <QApplication>
#include <QLabel>
#include <stdio.h>
#include "Thread.h"
#include "ventana.h"
Thread::Thread(){
stop=0;
}
void Thread::run(){
int argv=0;
app = new QApplication(argv,(char**) 0);
connect(this , SIGNAL(s_salir()), app, SLOT(quit()));
v= new ventana(app);
app->exec();
delete v;
delete app;
printf("hjhj\n"); fflush(stdout);
}
void Thread::inicia(){
start();
}
Thread::~Thread(){
}
void Thread::salir(){
emit s_salir();
QThread::yieldCurrentThread ();
}
void Thread::exec_e(){
exec();
}
Tread.h
#include <QApplication>
#include <QLabel>
#include <QThread>
#include "ventana.h"
class Thread : public QThread{
Q_OBJECT
signals:
void s_salir();
public:
void salir();
ventana* v;
int stop;
void inicia();
void exec_e();
Thread();
~Thread();
protected:
void run();
private:
QApplication * app;
};
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created: Wed 7. Mar 16:35:51 2012
** by: Qt User Interface Compiler version 4.7.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QScrollArea>
#include <QtGui/QScrollBar>
#include <QtGui/QStatusBar>
#include <QtGui/QTextBrowser>
#include <QtGui/QTextEdit>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QAction *actionSalir;
QWidget *centralwidget;
QTextBrowser *textBrowser;
QTextEdit *textEdit;
QScrollBar *verticalScrollBar;
QScrollArea *scrollArea;
QWidget *scrollAreaWidgetContents;
QTextEdit *textEdit_2;
QMenuBar *menubar;
QMenu *menuArchivo;
QMenu *menuAyuda;
QStatusBar *statusbar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(800, 600);
actionSalir = new QAction(MainWindow);
actionSalir->setObjectName(QString::fromUtf8("actionSalir"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
textBrowser = new QTextBrowser(centralwidget);
textBrowser->setObjectName(QString::fromUtf8("textBrowser"));
textBrowser->setGeometry(QRect(420, 280, 321, 241));
textEdit = new QTextEdit(centralwidget);
textEdit->setObjectName(QString::fromUtf8("textEdit"));
textEdit->setGeometry(QRect(50, 50, 321, 301));
verticalScrollBar = new QScrollBar(centralwidget);
verticalScrollBar->setObjectName(QString::fromUtf8("verticalScrollBar"));
verticalScrollBar->setGeometry(QRect(370, 50, 21, 301));
verticalScrollBar->setOrientation(Qt::Vertical);
scrollArea = new QScrollArea(centralwidget);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
scrollArea->setGeometry(QRect(500, 40, 231, 221));
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 229, 219));
textEdit_2 = new QTextEdit(scrollAreaWidgetContents);
textEdit_2->setObjectName(QString::fromUtf8("textEdit_2"));
textEdit_2->setGeometry(QRect(0, 0, 231, 221));
scrollArea->setWidget(scrollAreaWidgetContents);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 800, 21));
menuArchivo = new QMenu(menubar);
menuArchivo->setObjectName(QString::fromUtf8("menuArchivo"));
menuAyuda = new QMenu(menubar);
menuAyuda->setObjectName(QString::fromUtf8("menuAyuda"));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
menubar->addAction(menuArchivo->menuAction());
menubar->addAction(menuAyuda->menuAction());
menuArchivo->addSeparator();
menuArchivo->addAction(actionSalir);
retranslateUi(MainWindow);
QMetaObject::connectSlotsByName(MainWindow);
} // setupUi
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
actionSalir->setText(QApplication::translate("MainWindow", "Salir", 0, QApplication::UnicodeUTF8));
menuArchivo->setTitle(QApplication::translate("MainWindow", "Archivo", 0, QApplication::UnicodeUTF8));
menuAyuda->setTitle(QApplication::translate("MainWindow", "Ayuda", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_MAINWINDOW_H
ventana.cpp
#include "ventana.h"
ventana::ventana(QApplication * a)
{
setupUi(this);
show();
}
ventana::~ventana()
{
//dtor
}
ventana.h
#ifndef VENTANA_H
#define VENTANA_H
#include <QApplication>
#include <QLabel>
#include <QDialog>
#include <QtGui>
#include <ui_mainwindow.h>
class ventana: public QMainWindow, public Ui_MainWindow
{
Q_OBJECT
public:
ventana(QApplication * a);
virtual ~ventana();
protected:
private:
};
#endif // VENTANA_H
.pro (faltan las librerías de benuu, las agregué al makefile directamente).
######################################################################
# Automatically generated by qmake (2.01a) mié 7. mar 15:15:32 2012
######################################################################
TEMPLATE = lib
TARGET =
INCLUDEPATH += . C:\BennuGD\SDL-1.2.14\include\SDL C:\devbennu\bennugd\core\include C:\devbennu\bennugd\core\bgdrtm\include C:\devbennu\libpng C:\devbennu\SDL_mixer\include C:\devbennu\zlib C:\devBennu\bennuGD\modules\libdraw C:\devBennu\bennuGD\modules\libgrbase C:\devBennu\bennuGD\modules\librender C:\devBennu\bennuGD\modules\mod_map C:\devBennu\bennuGD\modules\libvideo C:\devBennu\bennuGD\modules\libblit C:\devBennu\bennuGD\modules\libfont
DEPENDPATH += . C:\BennuGD\Bennu\BennuGD\
# Input
SOURCES += main.cpp\
Thread.cpp\
ventana.cpp
HEADERS += Thread.h\
ventana.h
FORMS += mainwindow.ui
Makefile.Debug
#############################################################################
# Makefile for building: mod_proyectos
# Generated by qmake (2.01a) (Qt 4.7.0) on: mié 7. mar 16:51:38 2012
# Project: mod_proyectos.pro
# Template: lib
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
CFLAGS = -g -Wall $(DEFINES)
CXXFLAGS = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
INCPATH = -I"c:\qt-everywhere-opensource-src-4.7.0\include\QtCore" -I"c:\qt-everywhere-opensource-src-4.7.0\include\QtGui" -I"c:\qt-everywhere-opensource-src-4.7.0\include" -I"." -I"c:\BennuGD\SDL-1.2.14\include\SDL" -I"c:\devbennu\bennugd\core\include" -I"c:\devbennu\bennugd\core\bgdrtm\include" -I"c:\devbennu\libpng" -I"c:\devbennu\SDL_mixer\include" -I"c:\devbennu\zlib" -I"c:\devBennu\bennuGD\modules\libdraw" -I"c:\devBennu\bennuGD\modules\libgrbase" -I"c:\devBennu\bennuGD\modules\librender" -I"c:\devBennu\bennuGD\modules\mod_map" -I"c:\devBennu\bennuGD\modules\libvideo" -I"c:\devBennu\bennuGD\modules\libblit" -I"c:\devBennu\bennuGD\modules\libfont" -I"c:\qt-everywhere-opensource-src-4.7.0\include\ActiveQt" -I"debug" -I"." -I"c:\qt-everywhere-opensource-src-4.7.0\mkspecs\default"
LINK = g++
LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -shared -Wl,--out-implib,debug\libmod_proyectos.a
LIBS = -L"c:\qt-everywhere-opensource-src-4.7.0\lib" -lQtGuid4 -lQtCored4 -L"C:\BennuGD\Bennu\BennuGD" C:\BennuGD\Bennu\BennuGD\libgrbase.dll C:\BennuGD\Bennu\BennuGD\libbgdrtm.dll
QMAKE = c:\qt-everywhere-opensource-src-4.7.0\bin\qmake.exe
IDC = c:\qt-everywhere-opensource-src-4.7.0\bin\idc.exe
IDL = midl
ZIP = zip -r -9
DEF_FILE =
RES_FILE =
COPY = copy /y
COPY_FILE = $(COPY)
COPY_DIR = xcopy /s /q /y /i
DEL_FILE = del
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
INSTALL_FILE = $(COPY_FILE)
INSTALL_PROGRAM = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
####### Output directory
OBJECTS_DIR = debug
####### Files
SOURCES = main.cpp \
Thread.cpp \
ventana.cpp debug\moc_Thread.cpp \
debug\moc_ventana.cpp
OBJECTS = debug/main.o \
debug/Thread.o \
debug/ventana.o \
debug/moc_Thread.o \
debug/moc_ventana.o
DIST =
QMAKE_TARGET = mod_proyectos
DESTDIR = debug\ #avoid trailing-slash linebreak
TARGET = mod_proyectos.dll
DESTDIR_TARGET = debug\mod_proyectos.dll
####### Implicit rules
.SUFFIXES: .cpp .cc .cxx .c
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
####### Build rules
first: all
all: Makefile.Debug $(DESTDIR_TARGET)
$(DESTDIR_TARGET): ui_mainwindow.h $(OBJECTS)
$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)
qmake: FORCE
@$(QMAKE) -o Makefile.Debug mod_proyectos.pro
dist:
$(ZIP) mod_proyectos.zip $(SOURCES) $(DIST) mod_proyectos.pro c:\qt-everywhere-opensource-src-4.7.0\mkspecs\qconfig.pri c:\qt-everywhere-opensource-src-4.7.0\mkspecs\modules\qt_webkit_version.pri c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\qt_functions.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\qt_config.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\exclusive_builds.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\default_pre.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\default_pre.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\debug.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\debug_and_release.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\default_post.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\default_post.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\build_pass.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\rtti.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\exceptions.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\stl.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\shared.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\dll.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\warn_on.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\qt.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\thread.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\moc.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\win32\windows.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\resources.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\uic.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\yacc.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\lex.prf c:\qt-everywhere-opensource-src-4.7.0\mkspecs\features\include_source_dir.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
clean: compiler_clean
-$(DEL_FILE) debug\main.o debug\Thread.o debug\ventana.o debug\moc_Thread.o debug\moc_ventana.o
-$(DEL_FILE) debug\libmod_proyectos.a
distclean: clean
-$(DEL_FILE) $(DESTDIR_TARGET)
-$(DEL_FILE) Makefile.Debug
check: first
mocclean: compiler_moc_header_clean compiler_moc_source_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
compiler_moc_header_make_all: debug/moc_Thread.cpp debug/moc_ventana.cpp
compiler_moc_header_clean:
-$(DEL_FILE) debug\moc_Thread.cpp debug\moc_ventana.cpp
debug/moc_Thread.cpp: Thread.h
C:\qt-everywhere-opensource-src-4.7.0\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 Thread.h -o debug\moc_Thread.cpp
debug/moc_ventana.cpp: ui_mainwindow.h \
ventana.h
C:\qt-everywhere-opensource-src-4.7.0\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 ventana.h -o debug\moc_ventana.cpp
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all: ui_mainwindow.h
compiler_uic_clean:
-$(DEL_FILE) ui_mainwindow.h
ui_mainwindow.h: mainwindow.ui
c:\qt-everywhere-opensource-src-4.7.0\bin\uic.exe mainwindow.ui -o ui_mainwindow.h
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean compiler_uic_clean
####### Compile
debug/main.o: main.cpp Thread.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o main.cpp C:\BennuGD\Bennu\BennuGD\libgrbase.dll C:\BennuGD\Bennu\BennuGD\libbgdrtm.dll
debug/Thread.o: Thread.cpp Thread.h \
ventana.h \
ui_mainwindow.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\Thread.o Thread.cpp
debug/ventana.o: ventana.cpp ventana.h \
ui_mainwindow.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\ventana.o ventana.cpp
debug/moc_Thread.o: debug/moc_Thread.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_Thread.o debug\moc_Thread.cpp
debug/moc_ventana.o: debug/moc_ventana.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\moc_ventana.o debug\moc_ventana.cpp
####### Install
install: FORCE
uninstall: FORCE
FORCE:
mod_proyectos.cbp
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="prueba" />
<Option makefile_is_custom="1" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\mod_proyectos" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin\Release\mod_proyectos" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="Thread.cpp" />
<Unit filename="Thread.h" />
<Unit filename="main.cpp" />
<Unit filename="mainwindow.ui" />
<Unit filename="mod_proyectos.pro" />
<Unit filename="ui_mainwindow.h" />
<Unit filename="ventana.cpp" />
<Unit filename="ventana.h" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
(http://i247.photobucket.com/albums/gg149/rolix1/captura.png)
Gracias.