Table of Contents
2 Answers
Home Database Mysql Tutorial 在LInux上安装:mysql C connector :How to install MySQL Co

在LInux上安装:mysql C connector :How to install MySQL Co

Jun 07, 2016 pm 03:02 PM
i linux mysql Install

Hey there, I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know where to install them.I could copy the in

Hey there,

I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know where to install them.I could copy the include files into my project folder, but where can I put the lib file so that my compiled binary (and other binaries) can find it?

Thanks in advance!

 


 

答案:

the answer:

 

首先, 将 tar file,解压,然后:

其中位于lib 中的文件拷贝到 /usr/local/lib中

位于 include中的文件拷贝到 /usr/local/include中

位于bin中的文件拷贝到 /usr/local/bin 中;

注意: /usr/.. 文件夹可能时不可见的,所以,以上操作,要通通命令行来完成,祝你好运!

             其次,在编译时,不要忘了链接库的选项:

 

方法1:采用动态链接库编译:

采用动态链接库的编译:最后附上一个编译代码操作:

 gcc -o db.o db.c  -lmysql

 

 

方法2: 采用静态库来编译: (生成的文件可能比较大,嘿嘿 )

这个方法用动态连接库,比较那啥一点吧,看喜好,编译进去也行,2M多吧。

gcc -o db.o db.c  /usr/local/lib/libmysqlclient.a

 

方法3: 将连接器转入你的工程中

在你没有进行以上操作时,你也可以通过以下方法通过编译: 通过指定链接库的路径

gcc -o db.o db.c   -L mysql_connector_path/lib  -l mysql 

 

其中: mysql_connector_path 是你的mysql连接器所在的目录,通过 -L 选项来指定动态链接库的路径 ,这就是说通过在工程中包含该连接器目录,也能实现通过编译,更甚者把整个静态库都编译应用如方法2所采用的策略。

2 Answers

 

This is confusing, isn't it.. don't know why they don't make this more clear.

The lib/ files go in /usr/local/libThe include/ files go in /usr/local/includeThe bin/ files go in /usr/local/bin

The /usr/.. directory isn't visible through finder afaik so you have to go at it via commandline. Best of luck

Also, in your Xcode project, make sure you add a Linked Library by going to your Target's settings, General, then adding Linked Library "libmysqlclient.dylib"

 

 

 

 

 

Hey, on MySQL site you have a short presentation on how to install C connector for MySQL. You can access it here: http://dev.mysql.com/doc/refman/5.1/en/connector-c-building.html

 






Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1267
29
C# Tutorial
1239
24
MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Docker on Linux: Containerization for Linux Systems Docker on Linux: Containerization for Linux Systems Apr 22, 2025 am 12:03 AM

Docker is important on Linux because Linux is its native platform that provides rich tools and community support. 1. Install Docker: Use sudoapt-getupdate and sudoapt-getinstalldocker-cedocker-ce-clicotainerd.io. 2. Create and manage containers: Use dockerrun commands, such as dockerrun-d--namemynginx-p80:80nginx. 3. Write Dockerfile: Optimize the image size and use multi-stage construction. 4. Optimization and debugging: Use dockerlogs and dockerex

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

How to understand DMA operations in C? How to understand DMA operations in C? Apr 28, 2025 pm 10:09 PM

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.

How does MySQL differ from Oracle? How does MySQL differ from Oracle? Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

Linux Operations: Managing Files, Directories, and Permissions Linux Operations: Managing Files, Directories, and Permissions Apr 23, 2025 am 12:19 AM

In Linux, file and directory management uses ls, cd, mkdir, rm, cp, mv commands, and permission management uses chmod, chown, and chgrp commands. 1. File and directory management commands such as ls-l list detailed information, mkdir-p recursively create directories. 2. Permission management commands such as chmod755file set file permissions, chownuserfile changes file owner, and chgrpgroupfile changes file group. These commands are based on file system structure and user and group systems, and operate and control through system calls and metadata.

See all articles