Jump to content

fakarorg

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by fakarorg

  1. Try using this as a source file:

     

    #include <iostream>
    #include <mysql/mysql.h>
    using namespace std;
    
    int main()
    {
    cout << "Content-Type: text/plain\n\n";
    cout << "Hello, World!\n";
    
    try
    {
     cout << "MySQL Client Version: " << mysql_get_client_info() << endl ;
    }
    
    catch(exception& ex)
    {
     cout << "ERROR: " << ex.what() << endl;
    }
    
    return 0;
    }
    

     

    and compile it on the server using a cronjob with the command:

     

    g++ -o /home/<user>/public_html/cgi-bin/test.cgi /home/<user>/path/to/test.cpp -lmysqlclient

     

    Be sure to set the cronjob to run only once a day and then delete it, also make sure it's set to run several minutes into the future and set using PDT as a guide since that's the server's time zone.

     

    Thanks Shinryuu. It worked. So when I first linked it "dynamically" against libmysqlclient it didn't work on your servers because I have MySQL Client Version 5.5.32 while you have MySQL Client Version 5.1.56?

     

    Is there any option to install additional shared libraries on my site if I want to?

  2. I see you have java enabled in your configuration command. You'll need to have a Java-enabled account on Johnny to use Java. Since you aren't using it in your script, try configuring without any Java options enabled.

     

    This has nothing to do with Java. It shows the configuration used when building GCC. I wrote it here so you know that the compiler target is x86_64-redhat-linux. The CGI application is a native executable file and not a JAR or Java Bytecode file.

  3. Hello, Everyone.

     

    I'm having problems with my CGI executable on my site. It gives HTTP 500 Internal Server Error while I have no access to any detailed logs to be able to troubleshoot the problem. It works well on my computer.

     

    The permissions of the file are set correctly (755). And another "Hello, World!" CGI program works perfectly on the server. It seems to me that this is a linking issue.

     

    Here are the details of the executable:

     

     

    The executable is linked with the following libraries:

    Statically:

    libmysqlclient.a - Version 5.6.12

     

    Dynamically:

    linux-vdso.so.1 => (0x00007fffde5ff000)

    libdl.so.2 => /lib64/libdl.so.2 (0x0000003b48200000)

    libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003b48600000)

    librt.so.1 => /lib64/librt.so.1 (0x0000003b48a00000)

    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000003b54600000)

    libm.so.6 => /lib64/libm.so.6 (0x0000003b48e00000)

    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003b4c600000)

    libc.so.6 => /lib64/libc.so.6 (0x0000003b47e00000)

    /lib64/ld-linux-x86-64.so.2 (0x0000003b47a00000)

     

    Source Code:

    #include <iostream>
    #include <mysql.h>
    using namespace std;
    
    const string CRLF = "\r\n";
    
    int main()
    {
    cout << "Content-Type: text/plain" << CRLF << CRLF;
    cout << "Hello, World!" << CRLF;
    
    try
    {
     cout << "MySQL Client Version: " << mysql_get_client_info() << CRLF;
    }
    
    catch(exception& ex)
    {
     cout << "ERROR: " << ex.what() << CRLF;
    }
    
    return 0;
    }
    

     

    Compiled Using: gcc 4.7 with the following specifications:

    COLLECT_GCC=g++

    COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.0/lto-wrapper

    Target: x86_64-redhat-linux

    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux

    Thread model: posix

    gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC)

     

    Makefile:

    #Variables:
    INCLUDE_DIR = -I/usr/local/mysql/include
    LIBS_DIR = -L/usr/local/lib64
    STATIC_LIBS = -lmysqlclient
    DYNAMIC_LIBS = -ldl -lpthread -lrt
    
    STATIC_LINK_FLAG = -Wl,-Bstatic
    DYNAMIC_LINK_FLAG = -Wl,-Bdynamic
    
    LD_FLAGS = $(LIBS_DIR) $(STATIC_LINK_FLAG) $(STATIC_LIBS) $(DYNAMIC_LINK_FLAG) $(DYNAMIC_LIBS)
    
    #Rules:
    test.cgi: test.cpp
    g++ test.cpp $(INCLUDE_DIR) $(LD_FLAGS) -o test.cgi
    

×
×
  • Create New...