I've got Application.mk file which is ignored by ndk-build for some reason.
What i've got in it:
APP_PROJECT_PATH := $(call my-dir)
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_OPTIM := debug
APP_STL := gnustl_static
And flags on build is still:
-fno-exceptions -fno-rtti
And no gnustl includes.
What can be the problem?
Make sure the Application.mk is inside the jni folder, alongside the Android.mk.
Related
I have two versions of a function in an application, one implemented in CUDA and the other in standard C. They're in separate files, let's say cudafunc.h and func.h (the implementations are in cudafunc.cu and func.c). I'd like to offer two options when compiling the application. If the person has nvcc installed, it'll compile the cudafunc.h. Otherwise, it'll compile func.h.
Is there anyway to check if a machine has nvcc installed in the makefile and thus adjust the compiler accordingly?
Thanks a bunch,
You could try a conditional, like
ifeq (($shell which nvcc),) # No 'nvcc' found
func.o: func.c func.h
HEADERS += func.h
else
func.o: cudafunc.cu cudafunc.h
nvcc -o $# -c $< . . .
CFLAGS += -DUSE_CUDA_FUNC
HEADERS += cudafunc.h
endif
And then in the code that will call this function, it can test #if USE_CUDA_FUNC to decide which header to include and which interface to call.
This should work, included in your Makefile:
NVCC_RESULT := $(shell which nvcc 2> NULL)
NVCC_TEST := $(notdir $(NVCC_RESULT))
ifeq ($(NVCC_TEST),nvcc)
CC := nvcc
else
CC := g++
endif
test:
#echo $(CC)
For GNU make, the recipe line(s) (after test:) actually start with tab characters.
With the above preamble, you can use conditionals based on the CC variable to control the remainder of your Makefile.
You would change the test: target to whatever target you want to be built conditionally.
As a test, just run the above with make. You should get output of nvcc or g++ based on whatever was detected.
I'm trying to compile for Android on Windows, I've executed publish.sh and gameDevGuide.sh successfully.
my Android.mk has been modified by gameDevGuide.sh
When I run build_native.py I get the following error:
D:\cocos-projects\game\proj.android>build_native.py The Selected NDK
toolchain version was 4.8 ! Android NDK:
ERROR:D:\cocos-projects\game\proj.android../cocos2d/plugin/publish/protocols/android/Android.mk:PluginProtocolStatic:
LOCAL_SRC_FILES points to a missing file Android NDK: Check that
D:\cocos-projects\game\proj.android../cocos2d/plugin/publish/protocols/android/./lib/armeabi/libPluginProtocolStatic.a
exists
D:\cocos-projects\game\proj.android../cocos2d/plugin/publish/protocols/android/Android.mk contains:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) LOCAL_MODULE := PluginProtocolStatic
LOCAL_MODULE_FILENAME := libPluginProtocolStatic
LOCAL_SRC_FILES := ./lib/$(TARGET_ARCH_ABI)/libPluginProtocolStatic.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -llog
include $(PREBUILT_STATIC_LIBRARY)
The path D:\cocos-projects\game\proj.android../cocos2d/plugin/publish/protocols/android/./lib/armeabi/libPluginProtocolStatic.a seems wrong (notice the dot). libPluginProtocolStatic.a does not exist
Any idea how do I fix that? (Cocos2d-x 3.2alpha)
It says it's pointing to a missing NDK, I'd guess you moved or renamed the folder your android stuff is in. Run your setup.py the same way you did the first time (or if you never have, that's why).
Can you verify that plugins are publish correctly?
On windows you must have "make" command cygwin.
Try to open cygwin and write "make".
I'm trying to create a C program that can communicate with MySQL database via these two header files:
mysql.h
my_global.h
MySQL comes with mysql_config script that you can execute to find out where the include files and library files reside in the system. I was wondering how would you define it in the Makefile.am?
I currently have the following:
bin_PROGRAMS = db
db_SOURCES = db.c db.h
db_CFLAGS = -Wall `mysql_config --cflags --libs`
Is this the correct way?
I would search for mysql_config in configure.ac using the AX_WITH_PROG macro:
AX_WITH_PROG([MYSQL_CONFIG], [mysql_config], [AC_MSG_ERROR(mysql_config is required to build)])
so your users will be able to point the MYSQL_CONFIG environment variable at the program should it be installed in an unexpected location. And if the users haven't installed it, they will get a nice error message which alerts them to that fact before attempting to build.
I'd probably set up the cflags, cppflags, and libs in configure.ac as well, since they shouldn't change after configure is run:
MYSQL_CONFIG_CFLAGS=`$MYSQL_CONFIG --cflags`
MYSQL_CONFIG_CPPFLAGS=`$MYSQL_CONFIG --include`
MYSQL_CONFIG_LIBS=`$MYSQL_CONFIG --libs`
AC_SUBST([MYSQL_CONFIG_CFLAGS])
AC_SUBST([MYSQL_CONFIG_CPPFLAGS])
AC_SUBST([MYSQL_CONFIG_LIBS])
and put them in place in Makefile.am
db_CFLAGS = -Wall $(MYSQL_CONFIG_CFLAGS)
db_CPPFLAGS=$(MYSQL_CONFIG_CPPFLAGS)
db_LDADD=$(MYSQL_CONFIG_LIBS)
If all you need is the header files, you probably won't need to set up the cflags variable.
I did something similar:
in the configure.ac:
AC_DEFUN([CHECK_MYSQL_LIB],
[
AC_CHECK_PROGS(
MYSQL_CONFIG,
mysql_config
)
#In case it fails to find pthread then exit configure
if test "x${MYSQL_CONFIG}" != xmysql_config; then
echo "------------------------------------------"
echo " The mysql library and header file is "
echo " required to build this project. Stopping "
echo " Check 'config.log' for more information. "
echo "------------------------------------------"
(exit 1); exit 1;
else
MYSQL_CONFIG_CFLAGS=`$MYSQL_CONFIG --cflags`
MYSQL_CONFIG_CPPFLAGS=`$MYSQL_CONFIG --include`
MYSQL_CONFIG_LIBS=`$MYSQL_CONFIG --libs`
AC_SUBST([MYSQL_CONFIG_CFLAGS])
AC_SUBST([MYSQL_CONFIG_CPPFLAGS])
AC_SUBST([MYSQL_CONFIG_LIBS])
fi
])
And in the Makefile.am:
db_CPPFLAGS=$(MYSQL_CONFIG_CPPFLAGS)
db_LDFLAGS=$(MYSQL_CONFIG_LIBS)
Note that is better to add in the LDFLAGS instead of LDADD.
I'm trying to create a CUDA program (which I'm new at) that involves first grabbing information from a remote MySQL database. I'm using the Connector/C library from the MySQL website inside the program, before the CUDA calls.
I'm able to compile my program with MySQL when using gcc (without any CUDA code), but not with nvcc (the CUDA compiler). A peer who is familiar with CUDA mentioned to me that he had to compile some libjpg stuff he was doing with nvcc to avoid 'wrong architecture' and linking problems. He suggested that I compile the Connector/C library with nvcc. However, the Connector/C library uses CMake instead of a regular Makefile.
So, being new to CMake, I researched some stuff and found the toolchain file which sounded a lot like what I needed (found here). However, I am running into problems during the compile where all of the default includes and libraries used in Connector/C are not included. Specifically
-- Looking for include files HAVE_ALLOCA_H
-- Looking for include files HAVE_ALLOCA_H - not found.
and
-- Looking for strstr
-- Looking for strstr - not found
Those are just a couple examples, there are many more files that are not found.
Am I approaching this problem correctly? Is there a more obvious workaround that I am just not considering? If I am right in trying to compile MySQL Connector/C with CUDA, are there any suggestions for properly including the files and libraries required for Connector/C?
Thanks for your help.
If you can separate out the CUDA kernels from your mysql calls and place them in separate files, you can use your Makefile.
I keep all of the cuda kernels and such in .cu files and then I have a definition:
#
# CUDA Compilation Rules
#
define cuda-compile-rule
$1: $(call generated-source,$2) \
$(call source-dir-to-build-dir, $(subst .cu,.cubin, $2)) \
$(call source-dir-to-build-dir, $(subst .cu,.ptx, $2))
$(NVCC) $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(INCFLAGS) $(DEFINES) -o $$# -c $$<
$(call source-dir-to-build-dir, $(subst .cu,.cubin, $2)): $(call generated-source,$2)
$(NVCC) -cubin -Xptxas -v $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(INCFLAGS) $(DEFINES) $(SMVERSIONFLAGS) -o $$# $$<
$(call source-dir-to-build-dir, $(subst .cu,.ptx, $2)): $(call generated-source,$2)
$(NVCC) -ptx $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(INCFLAGS) $(DEFINES) $(SMVERSIONFLAGS) -o $$# $$<
endef
I've also included three functions for ease of use:
generated-source = $(filter %.cpp, $1) $(filter %.c, $1) $(filter %.f, $1) $(filter %.F, $1) $(filter %.cu, $1)
source-dir-to-build-dir = $(addprefix $(BUILDDIR)/, $1)
source-to-object = $(call source-dir-to-build-dir, \
$(subst .f,.o,$(filter %.f,$1)) \
$(subst .F,.o,$(filter %.F,$1)) \
$(subst .c,.o,$(filter %.c,$1)) \
$(subst .cpp,.o,$(filter %.cpp,$1)) \
$(if $(filter 1,$(USE_CUDA)),$(subst .cu,.cu.o,$(filter %.cu,$1))))
Then all you need to do is build up a list of source files and call:
$(foreach f,$(filter %.cu, $listOfFiles),$(call cuda-compile-rule,$(call source-to-object,$f),$f))
Note that in the function source-to-object there is a variable which I use to conditionally disable CUDA compilation USE_CUDA.
I am attempting to make a qt program on Windows 7 that uses a MySQL plugin.
I have compiled both qt and the mysql plugin with no problems using my minGW 32bit compiler.
However, I keep on getting an error like this:
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/dhatt/Desktop/testdb2'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN - I"..\..\..\..\QT\qt\include\QtCore" -I"..\..\..\..\QT\qt\include\QtGui" -I"..\..\..\..\QT\qt\include\QtSql" -I"..\..\..\..\QT\qt\include" -I"..\..\..\..\MySQL\bin" -I"..\..\..\..\QT\qt\include\ActiveQt" -I"debug" -I"..\..\..\..\QT\qt\mkspecs\win32-g++" -o debug\database.o database.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\testdb2.exe debug/database.o -L"c:\QT\qt\lib" -lmingw32 -lqtmaind -L C:\MySQL\lib\opt -LC:/QT/qt/plugins/sqldrivers -lqsqlmysqld -lQtSqld4 -lQtGuid4 -lQtCored4 -LC:\MySQL\lib\opt
C:/qt/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lqsqlmysqld
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\executable.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Users/dhatt/Desktop/testdb2'
mingw32-make: *** [debug] Error 2
I apologize in advance for being very verbose of what I did, but I am doing this partly for troubleshooting, and partly so any other lost souls don't end up wasting three weeks on this particular problem. :)
Here are my specs:
Windows 7 Nokia's Open Source QT
Qt SDK for Windows (C:\Qt\2010.04\qt)
Linux MinGW Version 5.1.6 (C\Linux\MinGW)
MySQL5 with C++ files (C:\MySQL5)
If you want to know how I installed qt, just follow this site's instructions:
http://www.jiggerjuice.net/software/qt-sql-drivers.html
These other sites may hold some extra information tidbits:
http://doc.qt.nokia.com/4.6/sql-driver.html
http://www.rag.com.au/linux/qt4howto.html
http://qtnode.net/wiki?title=Qt4_on_Windows (yes, I did check with Nokia's docs!!!)
http://doc.trolltech.com/qq/qq10-windows-deployment.html
This fellow mentioned about remaking qmake, which I am not doing unless I have a good reason.
http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/
I've already deleted the plugin cache once before, I hope I won't have to do it again...
http://doc.trolltech.com/4.2/plugins-howto.html#the-plugin-cache
http://ubuntuforums.org/showthread.php?t=1070155
If there is any confusion, between the two compilation option (creating the mysql libraries statically, or as a plugin), I chose for the plugin because it compiles quicker and I don't have to worry about licensing.
Generally, the big trouble of mysql to most people is to make a mingw compatible library. Generally, I did this with the mingw tools in ( https://olex.openlogic.com/packages/mingw-utils )...
c:\> cd MySQL\lib\opt
c:\mysql\lib\opt> reimp -d libmysql.lib
c:\mysql\lib\opt> dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a -k
I should have done it right since in my C:\MySQL\lib\opt, it has the two files:
libmysql.a
libmysql.lib
LIBMYSQL.def (not a typo)
and in the C:\MySQL\bin directory, I have:
libmySQL.bin (not a typo)
I had compiled the mysql plugin beforehand:
cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\lib\opt\libmysql.lib" mysql.pro
mingw32-make
As a result, I have in my C:\QT\qt\plugins\sqldrivers folder:
libqsqlmysql4.a
libqsqlmysqldq4.a
libqsqlodbc4.a
libqsqlodbcd4.a
qsqlmysql4.dll
qsqlmysqld4.dll
qsqlodbc4.dll
qsqlodbc4.dll
And in my C:\QT\bin folder
QtSql4.dll
QtSqld4.dll
So, I assume from this site ( http://www.qtforum.org/article/21352/how-to-compile-use-a-mysql-driver.html) that I got it right.
I didn't use the binaries of qt itself, I used the compiled qt files(also from Nokia), but reconfigured and recompiled them using mingw32-make. I had no errors. This was my configuration options for remaking qt.
-opensource
-nomake examples
-nomake demos
-no-sql-lite
-no-qt3support
-no-gif
-no-libpng
-no-libmng
-no-libtiff
-no-phonon
-no-phonon-backend
-no-multimedia
-no-audio-backend
-no-webkit
-no-script
-no-scripttools
-nodeclarative
-plugin-sql-mysql -l mysql -I C:\QT\qt\include -L C:\QT\qt\lib\opt
Here is my .pro file
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt -lmysql
# Input
SOURCES += database.cpp
I installed the plugin described in here:
C:\QT\qt
My path variables are:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Python26;C:\Linux\Cygwin\bin;C:\mingw-utils-0.3\bin;C:\QT\qt\bin;C:\MySQL\bin;C:\MySQL\include;C:\QT\mingw32\bin;C:\QT\mingw\bin;C:\QT\qt\plugins\sqldrivers
The qt command prompt added a few extra though, so I did all of this in the command prompt.
Setting up a MinGW/Qt only environment...
-- QTDIR set to C:\QT\qt
-- PATH set to C:\QT\qt\bin
-- Adding C:\QT\bin to PATH
-- Adding C:\Windows\System32 to PATH
-- QMAKESPEC set to win32-g++ (mingw is my only compiler so, this is unnecessary)
Although I either did all that already, or it is redundant. I only add this for the sake of completeness.
Here is my code (database.cpp):
#include <QtSql>
#include <iostream>
using namespace std;
int main( int argc, char ** argv )
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("---.---.---.---");
db.setDatabaseName("--------");
db.setUserName("------------");
db.setPassword("------------");
if (!db.open()) cout << "Failed to connect to mysql" << endl;
else cout << "Works finally." << endl;
QSqlDatabase::removeDatabase("QMYSQL");
exit ( 0 );
}
Very simple, yes?
I went to my directory with the example code, run
mingw32-make distclean
qmake
mingw32-make
and get the error message above. I've tried building a version with the release version only (no debug), and it still shows the same message, but with "cannot find -lqsqlmysq", so it is not that.
I've tried many things, but where should I look next to solve it; maybe someone can narrow it down for me, set me on the right path, or even better, solve his annoying problem.
Also, I plan to use python bindings with my code (I need PyQT + MySQL). If the proposed solution would prevent me from doing so, let me know.
Well, I'm going to solve my own problem, again, so let's make this fun!
This is your last chance.
After this, there is no turning back.
You download the PyQT.exe, the story ends. You wake up in your bed and you believe whatever you want to believe. You modify the .pro file, you stay in wonderland. And, I show you how deep the rabbit hole goes.
I eventually gave up and downloaded the .exe, which does have MySQL support out of the box. If mysql does not work, your application is the problem, and I recommend you read this post here ( http://lists.trolltech.com/qt-interest/2006-06/thread00292-0.html ) or follow the quote below:
The issue is that you either have to
use the addLibraryPath method or
create a QCoreApplication instance
before your first call to loading a
database
Believe me, manually installing PyQT+MySQL on Windows is a pain. But if you need some out of the way plugin to get at that the executable doesn't know, you have to go down the rabbit hole further.
Here is the new and improved .pro file:
LANGUAGE = C++
TEMPLATE = app
TARGET = executable
QT += core sql
QTPLUGIN += qsqlmysql
DEPENDPATH += .
INCLUDEPATH += C:\MySQL\bin
LIBS += -L C:\MySQL\lib\opt
# Input
SOURCES += database.cpp
Turns out I did have the right path to mysql, I was just confusing it with the .pro file that I had. After redownloading qt and following the steps above again, modifying my .pro file made all the difference.
But now I had to download SIP and PyQT. I followed the docs on there. There are a few more problems. Follow the links or the directions which are left there in case the information is removed.
If your SIP make install has an error where it is looking at Unix paths (/usr/bin) instead of DOS paths (C:\QT), look at this link http://old.nabble.com/Building-SIP-on-MinGW-:-problem-at-%22make-install%22-td28909249.html#
(short version: the problem is the sh.exe in one of your other linux compilers like cygwin or msys, change the name temporarily to force the make install to use DOS path naming):
If you configure PyQT and it spits out a file error that has to do with QTCore
Google pexports and download. Go to %QTdir%/bin. Then follow instructions or link ( http://jeethurao.com/blog/?p=18 )
pexports QtCore4.dll > QtCore4.def
dlltool –dllname QtCore4.dll –def QtCore4.def –output-lib libQtCore4.a
move libQtCore4.a ..\lib
And now you know kung-fu.
P.S: I never tried this method myself. This is a different, but untested (by me) method of compiling PyQT, done up by the trolls at Trolltech:
http://www.diotavelli.net/PyQtWiki/InstallingPyQTCommercialWin