13 Replies Latest reply on Oct 10, 2016 12:57 PM by Intel Corporation

    mysql compile error..

    hwanhee

      When you compile in my computer error message appears.


      Error message information is below.

       

      root@lim-13Z940-GH50K:~# $CC -lmraa -lmysqlclient -L/usr/lib/i386-linux-gnu -I/usr/include/mysql gps_0902.c -o gps_0902

      cc1: warning: include location "/usr/include/mysql" is unsafe for cross-compilation [-Wpoison-system-directories]

      /opt/poky-edison/1.7.2/sysroots/core2-32-poky-linux/lib/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'

      collect2: error: ld returned 1 exit status

       

      I would like to know a solution.

       

      I currently use Ubuntu 14.04 32bit.

       

       

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      #include <stdlib.h>
      #include <stdio.h>
      #include <mraa.h>
      #include <mysql.h>
      #include <pthread.h>
      //void gps_searching(void);
      #define DB_HOST "14.63.225.210"
      #define DB_USER "root"
      #define DB_PASS "appnimal"
      #define DB_NAME "appnimal_table"
      #define CHOP(x) x[strlen(x) - 1] = ' '
      int main() {   
          MYSQL *connection = NULL, conn;
          MYSQL_RES *sql_result;
          MYSQL_ROW sql_row;   
          int query_stat;   
          float la;   
          float lo;   
          char tel[12];   
          char query[255];   
          mysql_init(&conn);   
          if(!mysql_real_connect(&conn, DB_HOST, DB_USER, DB_PASS, DB_NAME, 3306, (char *) NULL, 0)) {       
              printf("%s\n",mysql_error(connection));   
              exit(1) ;
          }   
          printf("success\n") ;   
          mysql_close(connection);
          /*    for (;;) {
                  gps_searching();   
          }    */   
          return 0;
      }
      cs
        • 1. Re: mysql compile error..
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello hwanhee,
           
          I will try to help you find out why the cross compilation tools aren't letting you compile code that includes mysql.
           
          Please correct me if I'm wrong, you are trying to execute the command above on the root user, right?
           
          Could you please let us know step by step what you did (from installing the SDK to installing mysql and mraa) and the steps to replicate the issue? We would like to see if we can replicate this behavior.
           
          I'll be waiting for your reply.
          -Peter.

          • 2. Re: mysql compile error..
            hwanhee

            1 step. linux 32bit MCU SDK file(.sh) installed.   

                      1) https://downloadcenter.intel.com/download/25028

                      2) 설치_1.JPG download

                      3) in a terminal, "sudo sh poky-edison-glibc-i686-edison-image-core-32-toolchain-1.7.2.sh" enter as a command

             

            2 step. Install MRAA Library

                      1) in a terminal "sudo apt-get install git cmake swig libpcre3-dev python-dev build-essential" enter as a command

                      2) in a terminal "git clone http://github.com/intel-iot-devkit/mraa.git" enter as a command

                      3) in a terminal "cd mraa" enter as a command

                      4) in a terminal "mkdir build" enter as a command

                      5) in a terminal "sudo cmake .. -DBUILDSWIGNODE=OFF" enter as a command

                      6) in a terminal "sudo make" enter as a command

                      7) in a terminal "sudo make install" enter as a command

                      8) in a terminal "source /opt/poky-edison/1.7.2/environment-setup-core2-32-poky-linux" enter as a command

             

            3 step. Install mysql

                      1) in a terminal "sudo apt-get install mysql-server" enter as a command

                      2) mysql root passward setting

                      3) in a terminal "sudo apt-get install libmysqlclient-dev" enter as a command

             

            4 step. code compile

                     in a terminal "$CC -lmraa -lmysqlclient -L/usr/lib/i386-linux-gnu -I/usr/include/mysql gps_0902.c -o gps_0902" enter as a command

             

            and, when in ubuntu 64bit,

            Intel system studio IoT Edition (eclipse) should not be compiled.

            • 3. Re: mysql compile error..
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              I was testing the steps you provided us but on a Linux 64 bit machine (I don't have access to a 32 bit one). I received a different issue but one that could in fact be related, the issue I received was that mysql could not be found. I would like to ask you in which path you stored your code and in if you tried executing the command with sudo.

              I'll be waiting for your response.
              -Peter.

              • 4. Re: mysql compile error..
                hwanhee

                Hi Peter,

                 

                If you can not find or do not have to install mysql for libmysqlclient, you can not mysql.h did the path setting.

                 

                libmysqlclient install.

                 

                in a terminal "sudo apt-get install libmysqlclient-dev" enter as a command

                 

                or, mysql.h no path setting

                 

                in a terminal  "sudo find / -name mysql.h " enter as a command

                 

                Please write out the path to it.

                • 5. Re: mysql compile error..
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi hwanhee,
                   
                  I was able to replicate the error message using a slightly different command: $CC -lmraa gps_0902.c -o gps_0902 -I/usr/include/mysql/ -L/usr/lib -lmysqlclient.
                   
                  Let me try to investigate what could be happening and I'll get back to you.
                  -Peter.

                  • 6. Re: mysql compile error..
                    hwanhee

                    Hi Peter,

                     

                    I'll be waiting for your response.

                     

                    -Hwanhee

                    • 7. Re: mysql compile error..
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hello hwanhee,

                      Could you please enter the command mysql_config --libs? What's the output of that command?

                      Could you please try compiling the code but this time including the output of the previous command with $(mysql_config --lib)? Does it also throw an error? Could you please post a screenshot of the compilation?

                      Also, have you tried compiling this code on directly on Edison? If so, what happens?

                      I'll be waiting for your response.
                      -Peter.

                      • 8. Re: mysql compile error..
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        Hello hwanhee,

                        Do you have any updates about this?

                        -Peter.

                        • 9. Re: mysql compile error..
                          hwanhee

                          스크린샷, 2016-09-29 00:33:26.png

                           

                          i'm Sorry. I was very busy....

                           

                          Intel probably would have tried to compile in Edison. It was an error.

                           

                          I've re-installed the 64-bit Ubuntu.

                          • 10. Re: mysql compile error..
                            Intel Corporation
                            This message was posted on behalf of Intel Corporation

                            Hi hwanhee,

                            Thank you for sending us the screenshot, it will be of help.

                            I'm sorry, but I don't understand what you mean by "...Intel probably would have tried to compile in Edison. It was an error…”
                            Could you please explain us what you meant with this?

                            Also, were you able to compile your code including the mysql libraries with $(mysql_config --lib)? If so, what happened?
                            Could you please also let us know if you tried your code directly on Edison? If so, does it have any issues?

                            Let me know.
                            -Peter.

                            • 11. Re: mysql compile error..
                              hwanhee

                              You do not have a problem if you compile in Edison?

                              And when you try to compile in Edison, do you need Mary db?

                               

                              and "...Intel probably would have tried to compile in Edison. It was an error…” This need not understand.

                              I am the one caused by incorrect English.

                              • 12. Re: mysql compile error..
                                Intel Corporation
                                This message was posted on behalf of Intel Corporation

                                Hi hwanhee,

                                I have not tested the code directly on Edison (as I have not installed the other dependencies of the code), nevertheless, when I built the environment for cross compiling I did test if the code would compile with GCC and it did without issues.

                                However, it would be interesting to see if you can do this as well and in case you have installed the dependent packages on your board, to check if the code runs correctly on Edison.

                                Let me know if you can perform these tests.
                                -Peter.

                                • 13. Re: mysql compile error..
                                  Intel Corporation
                                  This message was posted on behalf of Intel Corporation

                                  Hi hwanhee,

                                  Do you have any updates about this?

                                  -Peter.