Ok, I think we've sorted out our own problems, and wanted to share what we
learned (and ask for guidance).

First of all...whoever took the time to add the Makefile.basic build option
was brilliant.  Having something separate (and simpler) than cmake allowed
us to isolate the problem to specifically cmake. Since we are so new to the
SOCI system, we were having difficulty finding our way.  But with this basic
building tool available we were able to confirm building SOCI was possible.
Huge thanks to whoever took the time to create *.basic.

Next, a few minutes over at the Cmake Twiki/FAQ page uncovered this gem of a
command:

        > make VERBOSE=1

This allowed us to see precisely how make was invoking c++.  Could I suggest
that whoever maintains the SOCI website, insert this one-liner in the
Installation documentation?  This simple line brought instant insight into
what was happening between cmake/gmake/c++.

And that brings me to the crux of the issue.

There are a series of options selected in the SociConfig.cmake file that are
tripping up our particular platform.

Specifically, c++ was being invoked with

        -ansi -std=c++98

A few minutes with the man page of the GNU C++ compiler on FreeBSD, and we
figured out the problem.  We needed to drop '-ansi' and '-std=c++98'. We
removed these and presto, buildable libraries resulted.

For anyone else who encounters this, a quick patch is included at the end of
this message.

My question is, what should we do with this information (other than share
with the list)? It seems like a bit of an awful hack to just drop these two
options from everyone who's looking to build SOCI. I strongly suspect these
compiler options were added over the years to improve code/compilation/error
catching -- and that the latest greatest GNU C++ is somehow treating them
more strictly.  But just removing them for everyone else may not be correct.

Is there some sort of additional conditional compilation directives that are
appropriate for SociConfig.cmake that can take into account our particular
environment (that might benefit others running modern FreeBSD)?


=================== PATCH ===========================

--- a/src/cmake/SociConfig.cmake
+++ b/src/cmake/SociConfig.cmake
@@ -29,13 +29,13 @@ if (MSVC)
 else()

   set(SOCI_GCC_CLANG_COMMON_FLAGS
-       "-pedantic -ansi -Wall -Wpointer-arith -Wcast-align -Wcast-qual
-Wfloat-equal -Wredundant-decls -Wno-long-long")
+        "-pedantic -Wall -Wpointer-arith -Wcast-align -Wcast-qual
-Wfloat-equal -Wredundant-decls -Wno-long-long")

   if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)

     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC
${SOCI_GCC_CLANG_COMMON_FLAGS}")
     if (CMAKE_COMPILER_IS_GNUCXX)
-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
+        #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
     endif()

   elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR
"${CMAKE_CXX_COMPILER}" MATCHES "clang")



> -----Original Message-----
> From: Jim Carroll [mailto:[email protected]]
> Sent: Tuesday, January 31, 2012 1:09 PM
> To: [email protected]
> Subject: [SOCI-users] Assistance w/ compilation issue --
> backends/postgresql/statement.cpp:448: error: 'strtoll' was not
> declared in this scope
>
> Hi,
>
> We're a group of new users to SOCI, trying to find some basic footing.
> We've run into a compilation stumbling block & can't grok our way
> around it.
> Specifically, when building the postgresql backend using the cmake
> build
> system, we receive the following error:
>
> [ 63%] Building CXX object
> backends/postgresql/CMakeFiles/soci_postgresql.dir/statement.cpp.o
> /usr/local/CN/src/soci/src/backends/postgresql/statement.cpp: In member
> function 'virtual long long int
> soci::postgresql_statement_backend::get_affected_rows()':
> /usr/local/CN/src/soci/src/backends/postgresql/statement.cpp:448:
> error:
> 'strtoll' was not declared in this scope
> *** Error code 1
>
> We see at the top of the code, strtoll() is pulled in from #include
> <cstdlib>, but the compiler can't seem to resolve the declaration.
>
> Details:
>
>       FreeBSD 8.2-RELEASE-p4
>       gcc version 4.2.1 20070719
>
> We used a fresh copy of SOCI was pulled from git.
>
>       cd /usr/local/CN/src
>       git clone git://soci.git.sourceforge.net/gitroot/soci/soci
>
> The cmake procedure we used was:
>
>       cd /usr/local/CN/src/soci
>       mkdir build
>       cd build
>       cmake -G "Unix Makefiles" -DWITH_ODCB=OFF ../
>       make
>
> Here's what we've tried so far:
>
> At first, we thought it was as simple as just adding an include
> directive to
> the compile (-I), but lack of familiarity with the cmake system made it
> impossible to quickly figure out how todo this (the cmake system looks
> really interesting - especially in light of our own internal need for
> multi-platform builds - will need to research this much much more
> carefully
> later). After awhile, we realized it was not the include path, so we
> moved
> onto other tries.
>
> Next, we thought maybe it was a namespace issue, so we tried to edit
> the
> offending line to specify scope. We tried:
>
>       Line 448:       long long result = ::strtoll(resultStr, &end, 0)
>
> And we tried:
>
>       Line 448:       long long result = std::strtoll(resultStr, &end, 0)
>
> But still got the same error.
>
> We wrote a quick program to confirm we didn't have something
> fundamentally
> broken with our compiler, and confirmed the following code can compile
> without any trouble:
>
>       #include <cstdlib>
>       long long f(const char* r, char* e) {
>               return strtoll(r, &e, 0);
>               }
>
> No problem.
>
> Clearly this is our own flat-out mis-understanding of cmake and how
> SOCI is
> put together. But because we're new to both systems, we're having
> trouble
> finding our way. But SOCI looks so fantastic, we're not willing to give
> up.
>
> Could anyone shed a little light on what we might be doing wrong, or
> point
> us to an RTFM that might push us in the right direction?
>
> Thanks
> Jim
>
>
>
>
> -----------------------------------------------------------------------
> -------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,
> MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Soci-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/soci-users



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to