MySql Connector/C++ in CMake

I installed MySql connector and i want to use it in my c++ app to connect to database, although i cannot link the library. I tried the way from other stack question so i did:

set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR "C:/MySQL/MySQL Connector C++ 8.4")
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/jdbc)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/jdbc/cppconn)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/mysqlx)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/mysqlx/common)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/mysqlx/devapi)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/mysql)
link_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/lib64)

target_link_libraries(2024__TAB_DSA__8_BRODZIAK
        PRIVATE cpr::cpr
        mysqlcppcon
)

target_compile_features(2024__TAB_DSA__8_BRODZIAK PRIVATE cxx_range_for)

in mine CMakeLists.txt but it produces error

C:Program FilesJetBrainsCLion 2023.3.4binmingwbin/ld.exe: cannot find -lmysqlcppcon: No such file or directory

I have path defined to my installed Connector and the includes of header files but i still cannot use the files itself and I am not sure why.

It seems like the linker cannot find the MySQL Connector/C++ library file named mysqlcppcon. This could be due to several reasons:

  1. The library name might be incorrect in the target_link_libraries command.
  2. The path specified in link_directories may not contain the actual library files or is incorrect.
  3. If you are using a different version of the connector or if your system is 32-bit, the library might be under a different folder instead of lib64.

Here’s what you can do to resolve the issue:

  • Verify that the library name is correct. Often, the library file is named mysqlcppconn. If this is the case, update your target_link_libraries command to use the correct name.

  • Check if the library files (.lib for static linking or .dll and .dll.a for dynamic linking on Windows) are actually present in ${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/lib64.

  • If your system is 32-bit or uses a different directory structure, ensure that you’re looking in the right directory for your libraries.

  • You might need to specify the exact name of the library file without the extension in your target_link_libraries, e.g., if there’s a file named libmysqlcppconn.lib, just mention mysqlcppconn.

Here’s an example of how you might adjust your CMake configuration:

set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR "C:/MySQL/MySQL Connector C++ 8.4")
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include)

link_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/lib64)

target_link_libraries(2024__TAB_DSA__8_BRODZIAK
 PRIVATE cpr::cpr
 mysqlcppconn # Assuming 'mysqlcppconn' is the correct name of your library
)

target_compile_features(2024__TAB_DSA__8_BRODZIAK PRIVATE cxx_range_for)

If none of these steps solve your problem, consider double-checking that you have installed MySQL Connector/C++ correctly and that all necessary environment variables are set up properly. Additionally, make sure that you’re using compatible versions of MySQL Connector/C++ with your compiler and build tools.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật