Browse Source

OSX compile g++/clang Data,ODBC,SQLite

Aleksandar Fabijanic 13 years ago
parent
commit
f7bd6a8fec

+ 2 - 51
Data/ODBC/Makefile

@@ -5,62 +5,13 @@
 #
 # Makefile for Poco ODBC
 #
-# For Unicode support, add following to COMMONFLAGS:
-#
-# -DUNICODE
-#
-# Unicode is supported only for UnixODBC
-#
 
 include $(POCO_BASE)/build/rules/global
 
-ifeq ($(LINKMODE),STATIC)
-LIBLINKEXT = $(STATICLIBLINKEXT)
-else
-LIBLINKEXT = $(SHAREDLIBLINKEXT)
-endif
-
-INCLUDE += $(POCO_ODBC_INCLUDE)
-SYSLIBS += $(POCO_ODBC_LIBRARY)
-
-ifeq ($(POCO_CONFIG),MinGW)
-# -DODBCVER=0x0300: SQLHandle declaration issue
-# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
-CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
-else ifeq ($(POCO_CONFIG),CYGWIN)
-# -DODBCVER=0x0300: SQLHandle declaration issue
-# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
-CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
-# CYGWIN platform has its own ODBC library in /lib/w32api 
-SYSLIBS += -L/lib/w32api -lodbc32 -lodbccp32
-else
-ifeq (0, $(shell test -e $(POCO_ODBC_LIBRARY)/libodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -lodbc -lodbcinst
-COMMONFLAGS += -DPOCO_UNIXODBC
-else
-ifeq (0, $(shell test -h $(POCO_ODBC_LIBRARY)/libodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -lodbc -lodbcinst
-COMMONFLAGS += -DPOCO_UNIXODBC
-else
-ifeq (0, $(shell test -e $(POCO_ODBC_LIBRARY)/libiodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -liodbc -liodbcinst
-COMMONFLAGS += -DPOCO_IODBC -I/usr/include/iodbc
-else
-ifeq (0, $(shell test -h $(POCO_ODBC_LIBRARY)/libiodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -liodbc -liodbcinst -I/usr/include/iodbc
-COMMONFLAGS += -DPOCO_IODBC
-else
-ifndef (POCO_NO_ODBC)
-$(warning No ODBC library found. Please install unixODBC or iODBC.)
-endif
-endif
-endif
-endif
-endif
-endif
+include ODBC.make
 
 objects = Binder ConnectionHandle Connector EnvironmentHandle \
-	Extractor ODBCMetaColumn ODBCException ODBCStatementImpl \
+	Extractor ODBCException ODBCMetaColumn ODBCStatementImpl \
 	Parameter Preparator SessionImpl TypeInfo Unicode Utility 
 
 target         = PocoDataODBC

+ 50 - 0
Data/ODBC/ODBC.make

@@ -0,0 +1,50 @@
+#
+# ODBC.make
+#
+# $Id: //poco/1.4/Data/ODBC/ODBC.make#1 $
+#
+# Makefile fragment for finding ODBC library
+#
+
+ifndef ODBCINCDIR
+ODBCINCDIR = /usr/include
+endif
+
+ifndef ODBCLIBDIR
+ifeq (0, $(shell test -d /usr/lib/$(OSARCH)-linux-gnu; echo $$?))
+ODBCLIBDIR = /usr/lib/$(OSARCH)-linux-gnu
+else ifeq (0, $(shell test -d /usr/lib64; echo $$?))
+ODBCLIBDIR = /usr/lib64
+else 
+ODBCLIBDIR = /usr/lib
+endif
+endif
+
+ifeq ($(LINKMODE),STATIC)
+LIBLINKEXT = .a
+else
+LIBLINKEXT = $(SHAREDLIBLINKEXT)
+endif
+
+INCLUDE += -I$(ODBCINCDIR)
+SYSLIBS += -L$(ODBCLIBDIR)
+
+ifeq ($(POCO_CONFIG),MinGW)
+# -DODBCVER=0x0300: SQLHandle declaration issue
+# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
+CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
+else ifeq ($(POCO_CONFIG),CYGWIN)
+# -DODBCVER=0x0300: SQLHandle declaration issue
+# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
+CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
+# CYGWIN platform has its own ODBC library in /lib/w32api 
+SYSLIBS += -L/lib/w32api -lodbc32 -lodbccp32
+else ifeq (0, $(shell test -e $(ODBCLIBDIR)/libodbc$(LIBLINKEXT); echo $$?))
+SYSLIBS += -lodbc -lodbcinst
+COMMONFLAGS += -DPOCO_UNIXODBC
+else ifeq (0, $(shell test -e $(ODBCLIBDIR)/libiodbc$(LIBLINKEXT); echo $$?))
+SYSLIBS += -liodbc -liodbcinst
+COMMONFLAGS += -DPOCO_IODBC -I/usr/include/iodbc
+else
+$(error No ODBC library found. Please install unixODBC or iODBC or specify ODBCLIBDIR and try again)
+endif

+ 2 - 2
Data/ODBC/src/ODBCStatementImpl.cpp

@@ -277,8 +277,8 @@ void ODBCStatementImpl::clear()
 		//(returned by 3.x drivers when cursor is not opened)
 		for (int i = 0; i < diagnostics.count(); ++i)
 		{
-			if (ignoreError =
-				(INVALID_CURSOR_STATE == std::string(diagnostics.sqlState(i))))
+			if ((ignoreError =
+				(INVALID_CURSOR_STATE == std::string(diagnostics.sqlState(i)))))
 			{
 				break;
 			}

+ 3 - 45
Data/ODBC/testsuite/Makefile

@@ -1,7 +1,7 @@
 #
 # Makefile
 #
-# $Id: //poco/Main/Data/ODBC/testsuite/Makefile#1 $
+# $Id: //poco/1.4/Data/ODBC/testsuite/Makefile#4 $
 #
 # Makefile for Poco SQLite testsuite
 #
@@ -14,50 +14,7 @@
 
 include $(POCO_BASE)/build/rules/global
 
-ifeq ($(LINKMODE),STATIC)
-LIBLINKEXT = $(STATICLIBLINKEXT)
-else
-LIBLINKEXT = $(SHAREDLIBLINKEXT)
-endif
-
-INCLUDE += $(POCO_ODBC_INCLUDE)
-SYSLIBS += $(POCO_ODBC_LIBRARY)
-
-ifeq ($(POCO_CONFIG),MinGW)
-# -DODBCVER=0x0300: SQLHandle declaration issue
-# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
-CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
-else ifeq ($(POCO_CONFIG),CYGWIN)
-# -DODBCVER=0x0300: SQLHandle declaration issue
-# -DNOMINMAX      : MIN/MAX macros defined in windows conflict with libstdc++
-CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
-# CYGWIN platform has its own ODBC library in /lib/w32api 
-SYSLIBS += -L/lib/w32api -lodbc32 -lodbccp32
-else
-ifeq (0, $(shell test -e $(POCO_ODBC_LIBRARY)/libodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -lodbc -lodbcinst
-COMMONFLAGS += -DPOCO_UNIXODBC
-else
-ifeq (0, $(shell test -h $(POCO_ODBC_LIBRARY)/libodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -lodbc -lodbcinst
-COMMONFLAGS += -DPOCO_UNIXODBC
-else
-ifeq (0, $(shell test -e $(POCO_ODBC_LIBRARY)/libiodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -liodbc -liodbcinst
-COMMONFLAGS += -DPOCO_IODBC -I/usr/include/iodbc
-else
-ifeq (0, $(shell test -h $(POCO_ODBC_LIBRARY)/libiodbc$(LIBLINKEXT); echo $$?))
-SYSLIBS += -liodbc -liodbcinst -I/usr/include/iodbc
-COMMONFLAGS += -DPOCO_IODBC
-else
-ifndef (POCO_NO_ODBC)
-$(warning No ODBC library found. Please install unixODBC or iODBC.)
-endif
-endif
-endif
-endif
-endif
-endif
+include $(POCO_BASE)/Data/ODBC/ODBC.make
 
 ##################################################################################################
 # Note:                                                                                          #
@@ -68,6 +25,7 @@ SYSLIBS += -lltdl -ldl
 objects = ODBCTestSuite Driver \
 	ODBCDB2Test ODBCMySQLTest ODBCOracleTest ODBCPostgreSQLTest \
 	ODBCSQLiteTest ODBCSQLServerTest ODBCTest SQLExecutor
+
 ifeq ($(POCO_CONFIG),MinGW)
     objects += ODBCAccessTest
 endif

+ 1 - 1
Data/ODBC/testsuite/src/ODBCDB2Test.cpp

@@ -607,7 +607,7 @@ void ODBCDB2Test::recreateLogTable()
 
 CppUnit::Test* ODBCDB2Test::suite()
 {
-	if (_pSession = init(_driver, _dsn, _uid, _pwd, _connectString))
+	if ((_pSession = init(_driver, _dsn, _uid, _pwd, _connectString)))
 	{
 		std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
 

+ 1 - 1
Data/ODBC/testsuite/src/ODBCMySQLTest.cpp

@@ -436,7 +436,7 @@ void ODBCMySQLTest::recreateLogTable()
 
 CppUnit::Test* ODBCMySQLTest::suite()
 {
-	if (_pSession = init(_driver, _dsn, _uid, _pwd, _connectString))
+	if ((_pSession = init(_driver, _dsn, _uid, _pwd, _connectString)))
 	{
 		std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
 

+ 1 - 1
Data/ODBC/testsuite/src/ODBCOracleTest.cpp

@@ -856,7 +856,7 @@ void ODBCOracleTest::recreateLogTable()
 
 CppUnit::Test* ODBCOracleTest::suite()
 {
-	if (_pSession = init(_driver, _dsn, _uid, _pwd, _connectString))
+	if ((_pSession = init(_driver, _dsn, _uid, _pwd, _connectString)))
 	{
 		std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
 

+ 1 - 1
Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp

@@ -571,7 +571,7 @@ void ODBCPostgreSQLTest::recreateLogTable()
 
 CppUnit::Test* ODBCPostgreSQLTest::suite()
 {
-	if (_pSession = init(_driver, _dsn, _uid, _pwd, _connectString))
+	if ((_pSession = init(_driver, _dsn, _uid, _pwd, _connectString)))
 	{
 		std::cout << "*** Connected to [" << _driver << "] test database." << std::endl;
 

+ 2 - 0
Data/SQLite/include/Poco/Data/SQLite/Extractor.h

@@ -46,6 +46,8 @@
 #include "Poco/Data/MetaColumn.h"
 #include "Poco/Data/DataException.h"
 #include "Poco/Data/Constants.h"
+#include "Poco/Data/Date.h"
+#include "Poco/Data/Time.h"
 #include "Poco/Any.h"
 #include "Poco/DynamicAny.h"
 #include "sqlite3.h"

BIN
Data/SQLite/testsuite/dsk.db


BIN
Data/SQLite/testsuite/dummy.db


+ 2 - 1
Data/SQLite/testsuite/src/SQLiteTest.cpp

@@ -356,9 +356,10 @@ void SQLiteTest::testInMemory()
 	assert (result == tableName);
 
 	tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", use(lastName), use(firstName), use(address), use(age), now;
-
+	
 	// load db from file to memory
 	Session mem (Poco::Data::SQLite::Connector::KEY, ":memory:");
+	sqlite3* p = 0; Any a = p; // ??? clang generated code fails to AnyCast without these
 	sqlite3* pMemHandle = AnyCast<sqlite3*>(mem.getProperty("handle"));
 	assert (Poco::Data::SQLite::Utility::fileToMemory(pMemHandle, "dummy.db"));
 

+ 1 - 1
Data/include/Poco/Data/LOBStream.h

@@ -74,7 +74,7 @@ protected:
 	typename BaseType::int_type readFromDevice()
 	{
 		if (_it != _lob.end())
-			return charToInt(*_it++);
+			return BaseType::charToInt(*_it++);
 		else
 			return -1;
 	}