CMake for PostgreSQL in CLion 1.2 Windows 10 - postgresql
Unable to build C++ file with PostgreSQL in CLion 1.2 EAP.
CMake file:
cmake_minimum_required(VERSION 3.3)
project(PostgreSQLTest)
find_package(PostgreSQL REQUIRED)
set(PostgreSQL_INCLUDE_DIRS, "C:\\Program Files\\PostgreSQL\\9.4\\include")
include_directories (${PostgreSQL_INCLUDE_DIRS})
set(SOURCES main.cpp)
add_executable(PostgreSQLTest ${SOURCES})
set(PostgreSQL_LIBRARIES, "C:\\Program Files\\PostgreSQL\\9.4\\lib")
target_link_libraries(PostgreSQLTest ${PostgreSQL_LIBRARIES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
CMakeLists.txt
main.cpp)
Build messages:
"C:\Program Files (x86)\JetBrains\CLion 142.4859.12\bin\cmake\bin\cmake.exe" --build C:\Users\darin\.CLion12\system\cmake\generated\f846c544\f846c544\Debug --target PostgreSQLTest -- -j 8
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/darin/.CLion12/system/cmake/generated/f846c544/f846c544/Debug
[ 50%] Linking CXX executable PostgreSQLTest.exe
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -llibpq
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [PostgreSQLTest.exe] Error 1
CMakeFiles\PostgreSQLTest.dir\build.make:96: recipe for target 'PostgreSQLTest.exe' failed
mingw32-make.exe[2]: *** [CMakeFiles/PostgreSQLTest.dir/all] Error 2
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/PostgreSQLTest.dir/all' failed
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/PostgreSQLTest.dir/rule' failed
Makefile:117: recipe for target 'PostgreSQLTest' failed
mingw32-make.exe[1]: *** [CMakeFiles/PostgreSQLTest.dir/rule] Error 2
mingw32-make.exe: *** [PostgreSQLTest] Error 2
Does anyone have experience with this build?
EDIT AFTER APPLYING CHANGES FROM COMMENT 2015-09-21
cmake_minimum_required(VERSION 3.3)
project(PostgreSQLTest)
set(PostgreSQL_ROOT, "C:\\Program Files\\PostgreSQL\\9.4")
find_package(PostgreSQL REQUIRED)
set(SOURCES main.cpp)
add_executable(PostgreSQLTest ${SOURCES})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
CMakeLists.txt
main.cpp)
Errors:
"C:\Program Files (x86)\JetBrains\CLion 142.4859.12\bin\cmake\bin\cmake.exe" --build C:\Users\darin\.CLion12\system\cmake\generated\f846c544\f846c544\Debug --target PostgreSQLTest -- -j 8
[ 50%] Building CXX object CMakeFiles/PostgreSQLTest.dir/main.cpp.obj
C:\Users\darin\ClionProjects\PostgreSQLTest\main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory
#include "libpq-fe.h"
^
compilation terminated.
mingw32-make.exe[3]: *** [CMakeFiles/PostgreSQLTest.dir/main.cpp.obj] Error 1
CMakeFiles\PostgreSQLTest.dir\build.make:61: recipe for target 'CMakeFiles/PostgreSQLTest.dir/main.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/PostgreSQLTest.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/PostgreSQLTest.dir/all] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/PostgreSQLTest.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/PostgreSQLTest.dir/rule] Error 2
Makefile:117: recipe for target 'PostgreSQLTest' failed
mingw32-make.exe: *** [PostgreSQLTest] Error 2
I have confirmed that libpq-fh.h does exist in C:\Program Files\PostgreSQL\9.4\include, so there must still be something incorrect in my Cmake file that's preventing the building.
Am I missing a target_link_libraries() that's required to build?
EDIT 2 AFTER APPLYING RECOMMENDED CHANGES
cmake_minimum_required(VERSION 3.3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
project(PostgreSQLTest)
set(PostgreSQL_ROOT "C:\\Program Files\\PostgreSQL\\9.4")
find_package(PostgreSQL REQUIRED)
set(SOURCES main.cpp)
add_executable(PostgreSQLTest ${SOURCES})
set(PostgreSQL_LIBRARIES "C:\\Program Files\\PostgreSQL\\9.4\\lib")
target_link_libraries(PostgreSQLTest ${PostgreSQL_LIBRARIES})
set(SOURCE_FILES
CMakeLists.txt
main.cpp)
ERRORS:
"C:\Program Files (x86)\JetBrains\CLion 142.4859.12\bin\cmake\bin\cmake.exe" --build C:\Users\darin\.CLion12\system\cmake\generated\f846c544\f846c544\Debug --target all -- -j 8
[ 50%] Building CXX object CMakeFiles/PostgreSQLTest.dir/main.cpp.obj
C:\Users\darin\ClionProjects\PostgreSQLTest\main.cpp:2:22: fatal error: libpq-fe.h: No such file or directory
#include "libpq-fe.h"
^
compilation terminated.
mingw32-make.exe[2]: *** [CMakeFiles/PostgreSQLTest.dir/main.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/PostgreSQLTest.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\PostgreSQLTest.dir\build.make:61: recipe for target 'CMakeFiles/PostgreSQLTest.dir/main.cpp.obj' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/PostgreSQLTest.dir/all' failed
Makefile:82: recipe for target 'all' failed
I made the recommended changes, tried several different orders for the compilation, and it's still failing.
Any ideas?
EDITS TO MAKE AFTER COMMENT ON 2015-10-05
cmake_minimum_required(VERSION 3.3)
project(PostgreSQLTest)
# For *modify* CMAKE_CXX_FLAGS, this should come after project() call.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Next line is not required, without it given path will be checked too.
#set(PostgreSQL_ROOT "C:\\Program Files (x86)\\PostgreSQL\\9.4")
#set(PostgreSQL ROOT "C:\\MinGW\\compiledLibs\\psql\\postgresql-9.6devel\\tmp_install\\usr\\local\\pgsql")
set(PostgreSQL ROOT "C:\\MinGW\\msys\\1.0\\local\\pgsql")
find_package(PostgreSQL REQUIRED)
message("PostgreSQL_LIBRARY_DIRS: ${PostgreSQL_LIBRARY_DIRS}")
# Now variables PostgreSQL_INCLUDE_DIRS, PostgreSQL_LIBRARIES are set. Just use them.
include_directories (${PostgreSQL_INCLUDE_DIRS})
link_directories(${PostgreSQL_LIBRARY_DIRS})
set(SOURCES main.cpp)
add_executable(PostgreSQLTest ${SOURCES})
target_link_libraries(PostgreSQLTest ${PostgreSQL_LIBRARIES})
set(SOURCE_FILES
CMakeLists.txt
main.cpp)
I don't find anything that indicates the posgres library used.
"C:\Program Files (x86)\JetBrains\CLion 142.4859.12\bin\cmake\bin\cmake.exe" --build C:\Users\darin\.CLion12\system\cmake\generated\f846c544\f846c544\Debug --target all -- -j 8
[ 50%] Building CXX object CMakeFiles/PostgreSQLTest.dir/main.cpp.obj
[100%] Linking CXX executable PostgreSQLTest.exe
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z9CloseConnP7pg_conn':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:9: undefined reference to `PQfinish'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z9ConnectDBv':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:19: undefined reference to `PQconnectdb'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:22: undefined reference to `PQstatus'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z19CreateEmployeeTableP7pg_conn':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:39: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:41: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:44: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:51: undefined reference to `PQclear'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z17InsertEmployeeRecP7pg_connPKcS2_':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:66: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:68: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:71: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:78: undefined reference to `PQclear'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z16FetchEmployeeRecP7pg_conn':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:88: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:90: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:93: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:98: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:101: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:102: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:105: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:110: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:112: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:114: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:117: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:122: undefined reference to `PQnfields'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:128: undefined reference to `PQfname'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:135: undefined reference to `PQgetvalue'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:132: undefined reference to `PQntuples'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:139: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:142: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:143: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:146: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:149: undefined reference to `PQclear'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z20RemoveAllEmployeeRecP7pg_conn':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:156: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:158: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:161: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:168: undefined reference to `PQclear'
CMakeFiles\PostgreSQLTest.dir/objects.a(main.cpp.obj): In function `Z17DropEmployeeTableP7pg_conn':
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:175: undefined reference to `PQexec'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:177: undefined reference to `PQresultStatus'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:180: undefined reference to `PQclear'
C:/Users/darin/ClionProjects/PostgreSQLTest/main.cpp:187: undefined reference to `PQclear'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\PostgreSQLTest.dir\build.make:96: recipe for target 'PostgreSQLTest.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/PostgreSQLTest.dir/all' failed
Makefile:82: recipe for target 'all' failed
mingw32-make.exe[2]: *** [PostgreSQLTest.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/PostgreSQLTest.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
Correct CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
project(PostgreSQLTest)
# For *modify* CMAKE_CXX_FLAGS, this should come after project() call.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Next line is not required, without it given path will be checked too.
set(PostgreSQL_ROOT "C:\\Program Files\\PostgreSQL\\9.4")
find_package(PostgreSQL REQUIRED)
# Now variables PostgreSQL_INCLUDE_DIRS, PostgreSQL_LIBRARIES, PostgreSQL_LIBRARY_DIRS are set. Just use them.
include_directories (${PostgreSQL_INCLUDE_DIRS})
link_directories(${PostgreSQL_LIBRARY_DIRS})
set(SOURCES main.cpp)
add_executable(PostgreSQLTest ${SOURCES})
target_link_libraries(PostgreSQLTest ${PostgreSQL_LIBRARIES})
set(SOURCE_FILES
CMakeLists.txt
main.cpp)
Main(but not solely) purpose of find_package(PostgreSQL) call is to set variables PostgreSQL_INCLUDE_DIRS, PostgreSQL_LIBRARIES, PostgreSQL_LIBRARY_DIRS (and some others). No needs to set these variables manually afterwards, just use them.
just use this, tested on mac.
cmake_minimum_required(VERSION 3.6)
project(postgres)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_custom_target(postgres COMMAND make -C ${postgres_SOURCE_DIR})
cmake done
Related
using legacy librealsense in qtcreator and cmake
I want to setup qt-creator for developing legacy librealsense in ubuntu16.04. I want to use CMake. I have librealsense installed on my system and the header files are in the "/usr/local/include" and the "librealsense.so" file is in the "/usr/local/lib". so I've created a simple CPP project with CMakeLists.txt and main.cpp files. my files are as follow: main.cpp file: #include <iostream> #include <librealsense/rs.hpp> int main() { rs::context ctx; std::cout << "Hello World!" << std::endl; return 0; } CMakeLists.txt file: cmake_minimum_required(VERSION 2.8) project(realsense_r200) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) find_library(librealsense REQUIRED) add_executable(${PROJECT_NAME} "main.cpp") target_link_libraries(${PROJECT_NAME} ${librealsense_LIBRARY}) target_include_directories(${PROJECT_NAME} PRIVATE ${librealsense_INCLUDE_DIR}) there are two problems: find_library(), can't find the librealsense and in the CMake cache list, in front of librealsense, I get NOT_FOUND. to solve the first problem I added the "librealsense.so" path manually in the cache list. so I have no errors in the generation of make files. but how can I set it up to find the path automatically? when I try to build my project I have undefined reference errors to some methods as below: CMakeFiles/realsense_r200.dir/main.cpp.o: In function `rs_apply_depth_control_preset(rs_device*, int)': main.cpp:(.text+0x61d): undefined reference to `rs_set_device_options' CMakeFiles/realsense_r200.dir/main.cpp.o: In function `rs_apply_ivcam_preset(rs_device*, rs_ivcam_preset)': main.cpp:(.text+0x734): undefined reference to `rs_reset_device_options_to_default' main.cpp:(.text+0x7d1): undefined reference to `rs_set_device_options' main.cpp:(.text+0x869): undefined reference to `rs_set_device_options' main.cpp:(.text+0x8ba): undefined reference to `rs_set_device_options' CMakeFiles/realsense_r200.dir/main.cpp.o: In function `rs::error::error(rs_error*)': main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x2a): undefined reference to `rs_get_error_message' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x74): undefined reference to `rs_get_failed_function' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x9b): undefined reference to `rs_get_failed_function' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x102): undefined reference to `rs_get_failed_args' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x129): undefined reference to `rs_get_failed_args' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x190): undefined reference to `rs_free_error' CMakeFiles/realsense_r200.dir/main.cpp.o: In function `rs::context::context()': main.cpp:(.text._ZN2rs7contextC2Ev[_ZN2rs7contextC5Ev]+0x30): undefined reference to `rs_create_context' CMakeFiles/realsense_r200.dir/main.cpp.o: In function `rs::context::~context()': main.cpp:(.text._ZN2rs7contextD2Ev[_ZN2rs7contextD5Ev]+0x1c): undefined reference to `rs_delete_context' CMakeFiles/realsense_r200.dir/build.make:94: recipe for target 'realsense_r200' failed CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/realsense_r200.dir/all' failed Makefile:83: recipe for target 'all' failed collect2: error: ld returned 1 exit status make[2]: *** [realsense_r200] Error 1 make[1]: *** [CMakeFiles/realsense_r200.dir/all] Error 2 make: *** [all] Error 2 18:32:02: The process "/usr/bin/cmake" exited with code 2. Error while building/deploying project realsense_r200 (kit: Desktop) When executing step "CMake Build" as you see in the CMakeLists.txt file I've linked the "librealsense.so" file to the executable, why I get these errors and how can I solve it? thanks for your help!!! # Edited Part I changed my cmake file as below: new CMake file: cmake_minimum_required(VERSION 2.8) project(realsense_r200) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) find_library(REALSENSE librealsense) find_package(Threads) add_executable(${PROJECT_NAME} "main.cpp") target_link_libraries(${PROJECT_NAME} ${REALSENSE} ${CMAKE_THREAD_LIBS_INIT}) the undefined errors have gone, but I have new errors as below: /usr/local/lib/librealsense.so: undefined reference to `std::thread::_State::~_State()#GLIBCXX_3.4.22' /usr/local/lib/librealsense.so: undefined reference to `typeinfo for std::thread::_State#GLIBCXX_3.4.22'CMakeFiles/realsense_r200.dir/build.make:95: recipe for target 'realsense_r200' failed CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/realsense_r200.dir/all' failed Makefile:83: recipe for target 'all' failed /usr/local/lib/librealsense.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())#GLIBCXX_3.4.22' collect2: error: ld returned 1 exit status make[2]: *** [realsense_r200] Error 1 make[1]: *** [CMakeFiles/realsense_r200.dir/all] Error 2 make: *** [all] Error 2 23:35:55: The process "/usr/bin/cmake" exited with code 2. Error while building/deploying project realsense_r200 (kit: Desktop) When executing step "CMake Build"
Error while running make command for srilm
While executing make command, I recieve the following error: /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::~File()': /home/cse/phd/16071009/NLP/misc/src/File.cc:127: undefined reference tolibiconv_close' /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*, char const*)': /home/cse/phd/16071009/NLP/misc/src/File.cc:167: undefined reference tolibiconv_close' /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*)': /home/cse/phd/16071009/NLP/misc/src/File.cc:217: undefined reference tolibiconv_close' /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(char const*, unsigned long, int)': /home/cse/phd/16071009/NLP/misc/src/File.cc:249: undefined reference tolibiconv_close' /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::reopen(std::string&, int)': /home/cse/phd/16071009/NLP/misc/src/File.cc:273: undefined reference tolibiconv_close' /home/cse/phd/16071009/NLP//lib/i686-m64/libmisc.a(File.o): In function File::fgetsUTF8(char*, int)': /home/cse/phd/16071009/NLP/misc/src/File.cc:387: undefined reference tolibiconv' /home/cse/phd/16071009/NLP/misc/src/File.cc:345: undefined reference to libiconv_open' /home/cse/phd/16071009/NLP/misc/src/File.cc:349: undefined reference tolibiconv_open' collect2: error: ld returned 1 exit status test -f ../bin/i686-m64/ngram make[2]: * [../bin/i686-m64/ngram] Error 1 make[2]: Leaving directory /home/cse/phd/16071009/NLP/lm/src' make[1]: *** [release-programs] Error 1 make[1]: Leaving directory/home/cse/phd/16071009/NLP' make: * [World] Error 2 [16071009#compute-01 NLP]$
The -liconv appears nowhere in the link command, so that's why you're getting the undefined references. Try putting: SYS_LIBRARIES = -L<path-to-libiconv_install> -liconv For example, if you install srilm on Ubuntu x64, edit this file: common/Makefile.site.i686-m64. Make sure the -L option points to the directory that has the libiconv.so or libiconv.a file. For me, libiconv install srilm on Ubuntu 18.04 x64 using make are locate on /usr/local/lib. So I add following line to common/Makefile.site.i686-m64: SYS_LIBRARIES = -L/usr/local/lib -liconv Solution from: http://mailman.speech.sri.com/pipermail/srilm-user/2014q3/001694.html
Compiling alsa-utils 1.1.0 on Raspberry Pi
I have compiled and installed alsa-lib 1.1.0 and moved on to compiling and installing the new alsa-util. The ./configure works: ./configure --disable-bat --disable-xmlto --disable-alsaconf --with-curses=ncursesw however the make fails and I have had no luck finding a resolution: Making all in topology make[1]: Entering directory '/home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology' gcc -g -O2 -o alsatplg topology.o -lasound -lasound -lm -ldl -lpthread topology.o: In function `main': /home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology/topology.c:99: undefined reference to `snd_tplg_new' /home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology/topology.c:105: undefined reference to `snd_tplg_verbose' /home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology/topology.c:107: undefined reference to `snd_tplg_build_file' /home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology/topology.c:114: undefined reference to `snd_tplg_free' /home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology/topology.c:110: undefined reference to `snd_tplg_free' collect2: error: ld returned 1 exit status Makefile:318: recipe for target 'alsatplg' failed make[1]: *** [alsatplg] Error 1 make[1]: Leaving directory '/home/pi/apps/alsa_utils/alsa-utils-1.1.0/topology' Makefile:352: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 I understand that this error means that undefined references exist but I cannot understand why? Thanks.
CMake cannot find include libpq-fe.h
I'm trying to build a program which requieres libpq-fe.h include file. This file is in E:\MinGW\msys\1.0\local\pgsql\include In my CMakeLists.txt I have: cmake_minimum_required(VERSION 3.0) # declare project PROJECT(localscp) set(pg_SOURCE_DIR /usr/local/pgsql) INCLUDE_DIRECTORIES( "E:/MinGW/msys/1.0/local/psql/include" ) # declare executables ADD_EXECUTABLE(localscp localscp.cc) TARGET_LINK_LIBRARIES(localscp dl pthread z pq) When I do cmake . I get: -- Configuring done -- Generating done -- Build files have been written to: E:/informemedico/localscp When I do mingw32-make I get: [ 50%] Building CXX object CMakeFiles/localscp.dir/localscp.cc.obj E:\informemedico\localscp\localscp.cc:24:22: fatal error: libpq-fe.h: No such file or directory compilation terminated. CMakeFiles\localscp.dir\build.make:62: recipe for target 'CMakeFiles/localscp.dir/localscp.cc.obj' failed mingw32-make[6]: *** [CMakeFiles/localscp.dir/localscp.cc.obj] Error 1 CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/localscp.dir/all' failed mingw32-make[5]: *** [CMakeFiles/localscp.dir/all] Error 2 makefile:82: recipe for target 'all' failed mingw32-make[4]: *** [all] Error 2 Why the compiler can't find that include file?.
fortran: using pgplot with eclipse photran
So I am really not a Fortran programmer at all, but I have some code I am working with that uses the pgplot graphics libraries in fortran. I am able to get the code running in fortran from the console using the following commands. gfortran -o simple discrete.f -lpgplot -IX11 discrete.f is the name of the file. So this works when I run it from the console. However, I want to run the code in the eclipse photran plugin so that I can use the debugger so that I can step through the code and observe some of the variables. I tried to put the -lpgplot and -IX11 flags in Eclipse, but I am getting errors about pgbbuf and pgnumb_ functions as undefined reference (which means that the -lpgplot function is not working when called from eclipse. Can anyone please tell me how to set the flags correctly to run this code in Photran so that I can compile it and see the pgplot figure come up? I am adding the console output: 02:57:05 **** Clean-only build of configuration Debug for project burglar_code_martin **** make clean rm -rf ./burglary_model.o burglar_code_martin 02:57:05 Build Finished (took 61ms) 02:57:05 **** Build of configuration Debug for project burglar_code_martin **** make all Building file: ../burglary_model.f Invoking: GNU Fortran Compiler gfortran -funderscoring -I/usr/lib -O0 -g -Wall -c -fmessage-length=0 -lpgplot -IX11 -o "burglary_model.o" "../burglary_model.f" Warning: Nonconforming tab character in column 1 of line 225 Warning: Nonconforming tab character in column 1 of line 228 ../burglary_model.f:155.27: call probcheck(frac,1,outc) 1 Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar) ../burglary_model.f:54.33: call probcheck(robprob,1,outcome) 1 Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar) ../burglary_model.f:95.30: call probcheck(placeprob,1,outcome) 1 Warning: Rank mismatch in argument 'problist' at (1) (rank-1 and scalar) ../burglary_model.f:206.36: subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar) 1 Warning: Unused dummy argument 'burgsatloc' at (1) ../burglary_model.f:206.44: subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar) 1 Warning: Unused dummy argument 'pic' at (1) ../burglary_model.f:206.51: subroutine output(A,burgsatloc,t,l,pic,screen,A0,Bbar) 1 Warning: Unused dummy argument 'screen' at (1) ../burglary_model.f:145.32: integer l,pic,screen,i,j,k,PGOPEN,burgsatloc(512,*),nbar,outc 1 Warning: Unused variable 'k' declared at (1) ../burglary_model.f:146.15: real rand,red,green,blue 1 Warning: Unused variable 'rand' declared at (1) ../burglary_model.f:143.53: subroutine initialize(burgsatloc,B,l,pic,screen,rbar,Bbar) 1 Warning: Unused dummy argument 'screen' at (1) ../burglary_model.f:4.58: integer i,j,n,l,pic,screen,guy,burgsatloc(512,512),k, 1 Warning: Unused variable 'k' declared at (1) Finished building: ../burglary_model.f Building target: burglar_code_martin Invoking: GNU Fortran Linker gfortran -lpgplot -IX11 -o "burglar_code_martin" ./burglary_model.o ./burglary_model.o: In function `output_': /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:241: undefined reference to `pgbbuf_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:242: undefined reference to `pgnumb_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:244: undefined reference to `pgenv_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:246: undefined reference to `pglab_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:247: undefined reference to `pgimag_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:253: undefined reference to `pgebuf_' ./burglary_model.o: In function `initialize_': /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:165: undefined reference to `pgopen_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:168: undefined reference to `pgpap_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:169: undefined reference to `pgask_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:170: undefined reference to `pgscir_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:175: undefined reference to `pgscr_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:181: undefined reference to `pgscr_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:187: undefined reference to `pgscr_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:193: undefined reference to `pgscr_' /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:199: undefined reference to `pgscr_' ./burglary_model.o: In function `implicit': /media/jaimini/workspace/eclipsejuno/burglar_code_martin/Debug/../burglary_model.f:109: undefined reference to `pgclos_' collect2: ld returned 1 exit status make: *** [burglar_code_martin] Error 1 02:57:05 Build Finished (took 209ms)