Opened 12 years ago

Closed 11 years ago

#34235 closed defect (fixed)

mysql-connector-cpp examples can't be build

Reported by: mkae (Marko Käning) Owned by: pixilla (Bradley Giesbrecht)
Priority: Normal Milestone:
Component: ports Version: 2.0.4
Keywords: Cc:
Port: mysql-connector-cpp

Description

When I try to build the examples it just fails. Looks like some paths aren't correctly set:

$ # copy examples source code directory into current folder, then let's try to build them again...
$ mkdir build; cd build
$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring examples
CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 2.8)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/marko/WC/examples/build
$ ls
total 64
drwxr-xr-x   6 marko  staff    204 Apr 27 23:05 ./
drwxr-xr-x  24 marko  staff    816 Apr 27 23:04 ../
-rw-r--r--   1 marko  staff  11872 Apr 27 23:05 CMakeCache.txt
drwxr-xr-x  28 marko  staff    952 Apr 27 23:05 CMakeFiles/
-rw-r--r--   1 marko  staff  15635 Apr 27 23:05 Makefile
-rw-r--r--   1 marko  staff   1420 Apr 27 23:05 cmake_install.cmake
$ make
Scanning dependencies of target connect
[  9%] Building CXX object CMakeFiles/connect.dir/connect.o
/Users/marko/WC/examples/connect.cpp:43:39: error: driver/mysql_public_iface.h: No such file or directory
/Users/marko/WC/examples/connect.cpp: In function ‘int main(int, const char**)’:
/Users/marko/WC/examples/connect.cpp:71: error: ‘sql’ is not a class or namespace
/Users/marko/WC/examples/connect.cpp:71: error: ‘driver’ was not declared in this scope
/Users/marko/WC/examples/connect.cpp:71: error: ‘sql’ is not a class or namespace
/Users/marko/WC/examples/connect.cpp:73: error: ‘sql’ cannot appear in a constant-expression
/Users/marko/WC/examples/connect.cpp:73: error: template argument 1 is invalid
/Users/marko/WC/examples/connect.cpp:73: error: invalid type in declaration before ‘(’ token
/Users/marko/WC/examples/connect.cpp:76: error: ‘sql’ cannot appear in a constant-expression
/Users/marko/WC/examples/connect.cpp:76: error: template argument 1 is invalid
/Users/marko/WC/examples/connect.cpp:76: error: invalid type in declaration before ‘(’ token
/Users/marko/WC/examples/connect.cpp:76: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:79: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:80: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:81: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:93: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:102: error: ‘sql’ cannot appear in a constant-expression
/Users/marko/WC/examples/connect.cpp:102: error: template argument 1 is invalid
/Users/marko/WC/examples/connect.cpp:102: error: invalid type in declaration before ‘(’ token
/Users/marko/WC/examples/connect.cpp:102: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:107: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:108: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:110: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:116: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:119: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:121: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:128: error: ‘sql’ cannot appear in a constant-expression
/Users/marko/WC/examples/connect.cpp:128: error: template argument 1 is invalid
/Users/marko/WC/examples/connect.cpp:128: error: invalid type in declaration before ‘(’ token
/Users/marko/WC/examples/connect.cpp:128: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:131: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:133: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:134: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:135: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:141: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:142: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:151: error: ‘sql’ cannot appear in a constant-expression
/Users/marko/WC/examples/connect.cpp:151: error: template argument 1 is invalid
/Users/marko/WC/examples/connect.cpp:151: error: invalid type in declaration before ‘(’ token
/Users/marko/WC/examples/connect.cpp:151: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:153: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:154: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:154: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:156: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:156: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:160: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:161: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:165: error: base operand of ‘->’ is not a pointer
/Users/marko/WC/examples/connect.cpp:166: error: request for member ‘reset’ in ‘stmt’, which is of non-class type ‘int’
/Users/marko/WC/examples/connect.cpp:173: error: request for member ‘reset’ in ‘con’, which is of non-class type ‘int’
/Users/marko/WC/examples/connect.cpp:174: error: expected type-specifier before ‘sql’
/Users/marko/WC/examples/connect.cpp:174: error: expected `)' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:174: error: expected `{' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:174: error: ‘::SQLException’ has not been declared
/Users/marko/WC/examples/connect.cpp:174: error: ‘e’ was not declared in this scope
/Users/marko/WC/examples/connect.cpp:174: error: expected `;' before ‘)’ token
/Users/marko/WC/examples/connect.cpp:182: error: request for member ‘reset’ in ‘con’, which is of non-class type ‘int’
/Users/marko/WC/examples/connect.cpp:183: error: expected type-specifier before ‘sql’
/Users/marko/WC/examples/connect.cpp:183: error: expected `)' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:183: error: expected `{' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:183: error: ‘::SQLException’ has not been declared
/Users/marko/WC/examples/connect.cpp:183: error: expected `;' before ‘)’ token
/Users/marko/WC/examples/connect.cpp:196: error: request for member ‘reset’ in ‘con’, which is of non-class type ‘int’
/Users/marko/WC/examples/connect.cpp:197: error: expected type-specifier before ‘sql’
/Users/marko/WC/examples/connect.cpp:197: error: expected `)' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:197: error: expected `{' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:197: error: ‘::SQLException’ has not been declared
/Users/marko/WC/examples/connect.cpp:197: error: expected `;' before ‘)’ token
/Users/marko/WC/examples/connect.cpp:205: error: expected type-specifier before ‘sql’
/Users/marko/WC/examples/connect.cpp:205: error: expected `)' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:205: error: expected `{' before ‘::’ token
/Users/marko/WC/examples/connect.cpp:205: error: ‘::SQLException’ has not been declared
/Users/marko/WC/examples/connect.cpp:205: error: ‘e’ was not declared in this scope
/Users/marko/WC/examples/connect.cpp:205: error: expected `;' before ‘)’ token
/Users/marko/WC/examples/connect.cpp:222: error: expected primary-expression before ‘catch’
/Users/marko/WC/examples/connect.cpp:222: error: expected `;' before ‘catch’
make[2]: *** [CMakeFiles/connect.dir/connect.o] Error 1
make[1]: *** [CMakeFiles/connect.dir/all] Error 2
make: *** [all] Error 2

Very sad. Don't know what to do, really.

Change History (6)

comment:1 Changed 12 years ago by mkae (Marko Käning)

I suggest that the port install its examples into

${prefix}/share/examples/mysql-connector-c++

which seems to be a standard location for examples in general.

There is absolutely no need to let macports build the example's executables. It would be just needed to supply all necessary files to be able to build them. (It looks like not all header files get installed as actually needed.)

comment:2 Changed 12 years ago by jmroot (Joshua Root)

Cc: pixilla@… removed
Owner: changed from macports-tickets@… to pixilla@…

comment:3 Changed 12 years ago by pixilla (Bradley Giesbrecht)

mk: try something like this:

SUBPORT=mysql55
sudo port install ${SUBPORT}-connector-cpp

sudo cp -R /opt/local/share/${SUBPORT}-connector-cpp/examples ./
cd examples

# Edit the EXAMPLE_* db connection parameters in examples.h as needed then:
for FILE in $(ls -1 *.cpp | sed 's,.cpp,,g');do /usr/bin/g++-4.2 -I/opt/local/include/${SUBPORT}-connector-cpp/driver -I/opt/local/include/${SUBPORT}-connector-cpp/cppconn -I/opt/local/include/${SUBPORT}-connector-cpp -I/opt/local/include/${SUBPORT}/mysql -I/opt/local/include -pipe -O2 -arch x86_64 -g -o ${FILE}.o -c ${FILE}.cpp;done

# or you can pass in the db connection parameters in like this:
for FILE in $(ls -1 *.cpp | sed 's,.cpp,,g');do /usr/bin/g++-4.2 -I/opt/local/include/${SUBPORT}-connector-cpp/driver -I/opt/local/include/${SUBPORT}-connector-cpp/cppconn -I/opt/local/include/${SUBPORT}-connector-cpp -I/opt/local/include/${SUBPORT}/mysql -I/opt/local/include -pipe -O2 -arch x86_64 -g -o ${FILE}.o -c ${FILE}.cpp -DEXAMPLE_HOST=\"tcp://127.0.0.1:3306\" -DEXAMPLE_USER=\"root\" -DEXAMPLE_PASS=\"pass\" -DEXAMPLE_DB=\"test\";done

# Create executables
for FILE in $(ls -1 *.cpp | sed 's,.cpp,,g');do /usr/bin/g++-4.2 -pipe -O2 -arch x86_64 -O3 -DNDEBUG -isysroot / -mmacosx-version-min=10.6 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/opt/local/lib -arch x86_64  ${FILE}.o -o ${FILE} -L/opt/local/lib/${SUBPORT}/mysql -L/opt/local/lib/${SUBPORT}-connector-cpp /opt/local/lib/${SUBPORT}-connector-cpp/libmysqlcppconn-static.a -lmysqlclient_r -lz;done

# Test executables
for FILE in $(ls -1 *.cpp | sed 's,.cpp,,g');do ./$FILE;done

comment:4 Changed 12 years ago by pixilla (Bradley Giesbrecht)

Resolution: fixed
Status: newclosed

See r96976

comment:5 Changed 11 years ago by mkae (Marko Käning)

Resolution: fixed
Status: closedreopened

Sorry, comment deleted, since I missed the "create executables" line above. Sorry for the noise.

Last edited 11 years ago by mkae (Marko Käning) (previous) (diff)

comment:6 Changed 11 years ago by mkae (Marko Käning)

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.