Compiling with MinGW JVMPI calls

I want to build a dll of a simple C program that is registerd as profiling agent and supplies the CPU-time.
I want to build it with the MinGW framework.
First I patched the jni_md.h as found in this forum,
then I tried to compile and link with
gcc -g -O2 -c -Id:/jdk1.4.1/include -Id:/jdk1.4.1/include/win32
-g -Id:/java/chess/c/include cputime.cpp
dllwrap --add-stdcall-alias -o cputime.dll -s cputime.o
While compiling succeded, the linking failed with
cputime.o(.eh_frame+0x11): In function `JVM_OnLoad':
d:/jdk1.4.1/include/jni.h:1913: undefined reference to `___gxx_personality_v0'
collect2: ld returned 1 exit status
What am I doing wrong?

Now I know a little bit more.
(Thanks to a kind person on the MinGW Forum).
I need to add the libstdc++ library.
Does anyone know the flags I have to use in the dllwrap command?

Similar Messages

  • Native Compilation with MinGW on 10GR2

    I have downloaded and installed 10gR2 on Windows 2000. It looks like the MinGW compiler is now supported on Windows. After looking in the spnc_commands file, I see the following near the end of the file:
    #GCC (MINGW) is now supported for plsql native comp on windows.
    #Download MinGW-3.1.0-1.exe from http://www.mingw.org.
    #The following two commands assume that GCC is installed at the default
    #location which is c:/MinGW. Change the paths to gcc and ld appropriately
    #if the installation is done in a different directory.
    #Finally, to use GCC for native comp, comment the above command line for cl.exe
    #and uncomment the following two comand lines.
    c:/MinGW/bin/gcc -c %(src) -O1 -I$(ORACLE_HOME)/plsql/public -I$(ORACLE_HOME)/plsql/include -o %(obj)
    c:/MinGW/bin/ld -shared -e 0x0 %(obj) $(ORACLE_HOME)/plsql/lib/libpncrt.a $(ORACLE_HOME)/lib/orapls10.lib -o %(dll)
    The last line references ORACLE_HOME/plsql/lib/libpncrt.a
    However, this directory or file does not exist anywhere on my Oracle installation or my MinGW directory.
    Does anyone know what this file is?
    Brett

    Thanks Brett,
    In reading Jens' paper, it almost looks like you can generate your own library file, but I think my unfamiliarity with the native compile option may be confusing me. I can't tell if the libraries being generated are the actual PL/SQL routines getting stored on the operating system or if I can generate "libpncrt.a" from some other file that is in unix format using a home brew "makefile" utility (not supplied in the paper).
    Since 10g has depricated the parameters PLSQL_NATIVE_MAKE_FILE_NAME and PLSQL_NATIVE_MAKE_UTILITY then the instructions in Jens' paper seem to be incompatable.
    Can you explain what "port-specific" means?
    Thanks Again,
    Bill

  • Problem with linker when compile with Mingw

    The error shows as:
    Compiler: Default compiler
    Building Makefile: "D:\code\c++\JVM\Makefile.win"
    Executing make...
    make.exe -f "D:\code\c++\JVM\Makefile.win" all
    gcc.exe main.o -o "java_VM.exe" -L"C:/Dev-Cpp/lib" -L"C:/Program Files/Java/jre1.5.0_07/bin/client" -ljvm
    main.o(.text+0x186):main.c: undefined reference to `_imp__JNI_CreateJavaVM@12'
    collect2: ld returned 1 exit status
    make.exe: *** [java_VM.exe] Error 1
    Execution terminated

    A Fix for "Your network preferences have been changed by another application" Error 
    In the Library/Preferences/SystemConfiguration/ folder delete the following:
    com.apple.airport.preferences.plist
    NetworkInterfaces.plist
    preferences.plist
    com.apple.nat.plist
    You will have to re-configure all your network settings since deleting.
    (10.4.10)
    Use Software Update to update your OS to last version of Tiger.  Install all the other updates that goes along w/it.

  • PL/SQL will compile with warnings but will not run

    I have a pl/sql package that will compile with warnings but no errors but when i try to run it I get an ORA-6508 error telling me there is an error somewhere in the package but I can't find it.
    I have two user schemas that use 2 slightly different versions of the package. I had to make slight code changes to one of the versions and when I made those changes it stopped running. The second version compiles and runs correctly.
    After going through a line by line comparison the first copy was still not running. I copied the second version of the code into the broken schema and commented out the additional lines of code that are not needed in this version.
    When I tried to compile and run this version it still fails with the same error.
    I am using Oracle XE and the databases are small.
    I can send on the code if necessary.
    Can anyone point me in the right direction?
    Thanks
    Susan

    I tried doing what you suggested but there are no errors as it is compiling correctly.
    It is only when I run the package through the debugger that I get the error. I have posted it below
    Connecting to the database Hess S3.
    Executing PL/SQL: ALTER SESSION SET PLSQL_DEBUG=TRUE
    Executing PL/SQL: CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '2086' )
    Debugger accepted connection from database on port 2086.
    Processing 59 classes that have already been prepared...
    Finished processing prepared classes.
    Exception breakpoint occurred at line 10 of BnmSkOTQ3jz5I52ZOxC4QNw.pls.
    $Oracle.EXCEPTION_ORA_6508:
    ORA-04063: package body "SHIPPING.LIFTINGSCHEDULE" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "SHIPPING.LIFTINGSCHEDULE"
    ORA-06512: at line 10
    Process exited.
    Disconnecting from the database Hess S3.
    Debugger disconnected from database.
    Regards
    susan

  • Kaffeine embedded crash fixed when compiled with libxcb support?

    From kaffeine website:
    Embedded Kaffeine crash fixed.
    This long standing bug is now fixed in current svn ...
    In order to make it possible, we have ported Kaffeine and xine to xcb (a thread-safe replacement for xlib).
    You can give it a try right now:
    1) install libxcb=>1.0
    2) install current xine-lib cvs (it contains xcb based video output plugins: xshm and xv)
    2) install current Kaffeine svn
    Notes
    a) Both xine-lib and Kaffeine have to be compiled with xcb support (autodetected, check configure results).
    b) Kaffeine will still work with xlib based video out plugins if compiled without xcb (but then, no fix!)
    From 0.8.4 changelog:
    * xine-part: support for xcb. Requires libxcb 1.0 and xine-lib 1.1.5. Fixes several issues.
    Any reason not to incorporate this? If it lives up to it's promises It could mean kde users only need ONE media player :-)  (I have 2 installed just to get DVD menus and embedding in konqueror without crashing)
    Any thoughts?
    Cheers,
    Steve.

    I felt that the laptop was possibly overheating and that is why I started down the road to call "customer support", thinking that a fan went out or there was damage to hardware due to it over heating.  And that road got me no where in a fast manner, and two "techs" telling me it was a software related issue and that I needed to reformat the laptop (twice) and re-install to factory settings.  Even when I did this, it still had the issue and they again told me that it was software related when there was no software on the computer except for Windows 7.  The only thing that customer support helped me with is the knowledge of next time I buy a laptop, but Dell or any other laptop besides a Toshiba.  That is too bad.
    Anyway, I tried to continue on with my thinking of a possible over heating issue, so I blew air into the vents and fins of the laptop.  A lot of dust came out.  I kept blowing air into the vents until no more dust came.
    My wife had to re-install everything again to her laptop after I got the major items re-installed.  She has been running it for the last day or so with no issues.  We hope that this was the issue.  I know she enjoys the laptop when it was running well.
    I guess we will see how it goes.

  • 11g Instaclient, Centos Error Module compiled with module API=20050922

    While we are trying to connect remote 11g database we are getting errors
    a. httpd log
    PHP Warning: PHP Startup: fileinfo: Unable to initialize module\nModule compiled with module API=20050922, debug=0, thread-safety=0\nPHP compiled with module API=20060613, debug=0, thread-safety=0\nThese options need to match\n in Unknown on line 0
    PHP Warning: PHP Startup: memcache: Unable to initialize module\nModule compiled with module API=20050922, debug=0, thread-safety=0\nPHP compiled with module API=20060613, debug=0, thread-safety=0\nThese options need to match\n in Unknown on line 0
    b. Browser
    Fatal error: Call to undefined function oci_connect() in /usr/www/developers/checkConnectServer.php on line 11
    We have trying from a combination Centos 5.4, PHP 5.2.10, oracle-instantclient-basic-11.1.0.1-1.i386, oci8-1.4.2
    Kindly help if some one knows fix; Thanks in advance

    If you have a model project that has objects referenced by the view controller/UI project then you need to explicitly include them in the deployment. Unlike in embedded OC4J they wont be automatically included.
    Create an ADF library deployment profile in the model project and include the generated library in your UI project war file. You can add this jar to the project Libraries/Classpath then make sure it is included in the WEB-INF/lib Contributors list.

  • Problem with building BerkeleyDB 4.8.24 with mingw

    Good day!
    I downloaded db-4.8.24.NC.tar.gz, configured it with
    "../dist/configure --disable-shared --disable-replication --enable-mingw --enable-static"
    and runned "make"
    After some time I received compilation problem like this (see below):
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_failchk.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_failchk.c -o lock_failchk.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_id.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_id.c -o lock_id.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_list.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_list.c -o lock_list.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_method.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_method.c -o lock_method.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_region.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_region.c -o lock_region.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_stat.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_stat.c -o lock_stat.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_timer.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_timer.c -o lock_timer.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../lock/lock_util.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../lock/lock_util.c -o lock_util.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../mutex/mut_alloc.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../mutex/mut_alloc.c -o mut_alloc.o
    ./libtool --mode=compile gcc -c -I. -I../dist/..  -O3  ../dist/../mutex/mut_failchk.c
    libtool: compile: gcc -c -I. -I../dist/.. -O3 ../dist/../mutex/mut_failchk.c -o mut_failchk.o
    ../dist/../mutex/mut_failchk.c: In function '__mut_failchk':
    ../dist/../mutex/mut_failchk.c:53: error: incompatible type for argument 3 of 'dbenv->is_alive'
    ../dist/../mutex/mut_failchk.c:53: note: expected 'db_threadid_t' but argument is of type 'int'
    ../dist/../mutex/mut_failchk.c:57: error: incompatible type for argument 3 of 'dbenv->thread_id_string'
    ../dist/../mutex/mut_failchk.c:57: note: expected 'db_threadid_t' but argument is of type 'int'
    make: *** [mut_failchk.o] Error 1
    sh-3.1$ make
    I have MSYS 1.0.11, mingw 5.1.6, GCC 4.4.0

    My guess is that the GCC 3.4.5 header files somewhere typedef `pthread_t` as `unsigned long int`.
    I am also trying to compile Berkeley DB 4.8.24 with MinGW gcc version 4.4.0, and I received the same error. Fortunately, though, I was able to proceed after changing line 113 of `db.h` in the `build_unix` folder from:
    typedef pthread_t db_threadid_t;
    to:
    typedef u_int32_t db_threadid_t;

  • Custom kernel compilation with abs..

    Been trying out custom kernel compilation with abs, since i only know the regular make menuconfig style, thought that this would be a good thing to learn.
    here is my kernel pkgbuild (showing only the part that i changed):
    # Contributor: dibblethewrecker <dibblethewrecker>
    pkgname=kernel26
    pkgver=2.6.17.13
    pkgrel=1
    pkgdesc="The Linux Kernel 2.6.x.y and modules (IDE support), built with ... patchset"
    url="http://www.kernel.org"
    depends=('module-init-tools')
    install=kernel26.install
    ##### if you are using a single patch from a patchset you can add the name, without it's extention, below
    patch=2.6.18-rc6-mm2
    ##### add the names of any patches to this section, ensure you have the correct extentions!
    source=($patch.bz2 config ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$pkgver.tar.bz2 )
    I want to install the 2.6.18-rc6-mm2, so i downloaded that patch and put it in the same folder as PKGBUILD.
    I copied kernel26.install and put it in the same folder as the PKGBUILD.
    when running makepkg it asks for a config file.. So i copied the config file in /var/abs/kernels/kernel26/. But this will build with an old config file.. how can i as when doing the manual way, do a make menuconfig and enter the settings i want for this kernel??
    thanks

    I'd say it does too, and I think the problem is here:
    jinn wrote:I copied kernel26.install and put it in the same folder as the PKGBUILD.
    Did you just copy the install script, or did you edit it to create an image with a unique name? The script is hardcoded to create an image called kernel26.img i.e. the image name required by the stock kernel, so if you ran it as it is, you have overwritten the images for your stock kernel with images for your new kernel.
    You might still be able to boot your new kernel with kernel26-fallback.img, but if not you will have to boot your stock kernel using the initrd image, which will have been unaffected.
    Once your system is running again, you need to regenerate the kernel26 images using mkinitcpio, and then you can start debugging the problem with your new kernel.
    Of course, if you've already edited kernel26.install for your new kernel, ignore the above, and I'll start again.

  • Building regular DLL based on static libs compiled with _AFXDLL

    I am trying to build a regular DLL that depends upon a set of static libs I get from elsewhere. The static libs are compiled with _AFXDLL and _AFXEXT and /MD. (The static libs are used by a different application that uses shared MFC libs.)
    I can link the dll, but when it runs it fails to find CRuntimeType information for classes in those static libs. Specifically, some source in the static libs is calling:
    AFX_MODULE_STATE *afxs = AfxGetModuleState();
    and looking thru the afxs->m_classList which happens to be NULL. (There should be lots of classes there.)
    Currently my regular DLL is linking agains the static MFC libs.
    To be clear, I do not want to export any MFC classes from my dll, the MFC classes are only used internally by the static libs I'm linking my dll against. That's why I am using a regular (not mfx extension) dll.
    Do I need to link my dll with shared mfc? I have a fair amount of exported functions. I would have to add
    AFX_MANAGE_STATE(AfxGetStaticModuleState( ))
    to every exported function right?

    Ok, I've tried a few things and I know more of what's going on.
    I linked my dll with the shared mfc (_AFXDLL) and added the AFX_MANAGE_STATE(AfxGetStaticModuleState( )) to some of the exported functions to try it out. It switches to the dll's AFX_MODULE_STATE alright, but the class list is empty. If I break in the CWinApp initializer (before any exported functions are called) for the dll, the class list is there. So where did it go?
    Well I stepped thru in the debugger and here's what's happening:
    _CRT_INIT creates the AFX_MODULE_STATE for the dll and AfxClassInit() gets called lots of times to add the runtime class info. Looks like this is being done by static constructors in the static libs I'm linking my dll against. So far so good.
    Then after that, InternalDllMain comes along and calls AfxInitExtensionModule( state, ... )
    Here's the problem, AfxInitExtensionModule, in addition to modifing it's state argument like you would expect it to, it also has this curious line:
    pModuleState->m_classList.m_pHead = pModuleState->m_pClassInit;
    where pModuleState is the current (dll's) state. So my class list is wiped out because the m_pClassInit slot is NULL. The AFX_MODULE_STATE constructer sets the m_pClassInit member to NULL. Looks like it's supposed to be some kind of backup so I have no clue what AfxInitExtensionModule is doing what it's doing.
    Is this a bug or do I still not have something set up right???

  • Using GDB to debug a code compiled with Sun cc

    When using gdb to debug C code compiled with Sun's cc, the step-into doesn't work, i can only "step into" a function if i put a breakpoint on it. Also, sometimes if i set a breakpoint on a function name, like "break foo", gdb indeed breaks when foo is reached, but without showing the source code (this i could not reproduce with a small demo program).
    I am using Sun Studio 12 on a SunOS 5.10 sun4u sparc machine.
    My demo program is:
    #include <stdio.h>
    #include <strings.h>
    void func1(str)
    char str;
    printf("This is the first line\n");
    printf("STR: %s\n",str);
    int main()
    char str[10];
    strcpy(str,"lalalal");
    printf("Calling func1\n");
    func1(str);
    printf("Returned from func1\n");
    The compilation command i run is:
    cc -c -g step_into.c -o step_into.o
    cc -g -o step_into step_into.o
    When running the program with gdb, the "step" command does not step into func1, but runs it like "next".
    I know there's the dbx debugger, but if there's a way to fix this with gdb - it is much preferable for us. Switching to dbx is not really feasible for us.
    Regards,
    Yael

    Hello Yael,
    I tried your example on my laptop (OpenSolaris x86/x64) with Sun Studio 12 update 1
    and GDB 6.3.50 - it works properly:
    $ gdb dist/Debug/SunStudio-Solaris-x86/forum_c_20091230
    GNU gdb 6.3.50_2004-11-23-cvs
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "i386-pc-solaris2.11"...
    (gdb) break main
    Breakpoint 1 at 0x8050a87: file src/args.c, line 15.
    (gdb) run
    Starting program: /export/home/nikm/SunStudioProjects/Forum_C_20091230/dist/Debug/SunStudio-Solaris-x86/forum_c_20091230
    Breakpoint 1, main () at src/args.c:15
    15         printf("Calling func1\n");
    Current language:  auto; currently minimal
    (gdb) next
    Calling func1
    16         func1(str);
    (gdb) step
    This is the first line
    func1 (str=0x80477ba "lalalal") at src/args.c:7
    7         printf("STR: %s\n",str);
    (gdb) Could you please download and try Sun Studio 12 update 1?
    It is available for free. Here is the web page:
    http://developers.sun.com/sunstudio/
    BTW, which GDB version do you use?
    I'll try it on a sparc system and let you know.
    Thanks.
    Nik
    P.S.: there is a typo in the source code:
    void func1(str)
    *char *str;I think it should be:
    void func1(char *str)Probably a copy-paste problem.
    Please use "CODE" mode when you copy-paste source lines (selected text, press 'CODE' button).

  • PHP5 package compiled with LDAP support?

    When I check phpinfo() it appears the PHP5 package was compiled with LDAP support but for some reason when I try a ldap_connect function in php it errors with 'Fatal error: Call to undefined function ldap_connect() in ...'
    Anybody have any idea what the problem is?
    Thanks,
    Craig

    I'm not sure about the php.ini thing, I've combed through it looking for idea's as well, but the only ldap string in the whole file is this 'extension=php_ldap.dll' and that doesn't apply to Arch.
    Also at http://www.php.net/ldap it talks about requirements etc and I'm almost thinking that the php5 package is not compiled with ldap even though when I do a phpinfo() it does show '--with-ldap' in the compile settings.

  • Example code for java compiler with a simple GUI

    There is no question here (though discussion of the code is welcome).
    /* Update 1 */
    Now available as a stand alone or webstart app.! The STBC (see the web page*) has its own web page and has been improved to allow the user to browse to a tools.jar if one is not found on the runtime classpath, or in the JRE running the code.
    * See [http://pscode.org/stbc/].
    /* End: Update 1 */
    This simple example of using the JavaCompiler made available in Java 1.6 might be of use to check that your SSCCE is actually what it claims to be!
    If an SSCCE claims to display a runtime problem, it should compile cleanly when pasted into the text area above the Compile button. For a compilation problem, the code should show the same output errors seen in your own editor (at least until the last line of the output in the text area).
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.EventQueue;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.SwingWorker;
    import javax.swing.border.EmptyBorder;
    import java.util.ArrayList;
    import java.net.URI;
    import java.io.ByteArrayOutputStream;
    import java.io.OutputStreamWriter;
    import javax.tools.ToolProvider;
    import javax.tools.JavaCompiler;
    import javax.tools.SimpleJavaFileObject;
    /** A simple Java compiler with a GUI.  Java 1.6+.
    @author Andrew Thompson
    @version 2008-06-13
    public class GuiCompiler extends JPanel {
      /** Instance of the compiler used for all compilations. */
      JavaCompiler compiler;
      /** The name of the public class.  For 'HelloWorld.java',
      this would be 'HelloWorld'. */
      JTextField name;
      /** The source code to be compiled. */
      JTextArea sourceCode;
      /** Errors and messages from the compiler. */
      JTextArea output;
      JButton compile;
      static int pad = 5;
      GuiCompiler() {
        super( new BorderLayout(pad,pad) );
        setBorder( new EmptyBorder(7,4,7,4) );
      /** A worker to perform each compilation. Disables
      the GUI input elements during the work. */
      class SourceCompilation extends SwingWorker<String, Object> {
        @Override
        public String doInBackground() {
          return compileCode();
        @Override
        protected void done() {
          try {
            enableComponents(true);
          } catch (Exception ignore) {
      /** Construct the GUI. */
      public void initGui() {
        JPanel input = new JPanel( new BorderLayout(pad,pad) );
        Font outputFont = new Font("Monospaced",Font.PLAIN,12);
        sourceCode = new JTextArea("Paste code here..", 15, 60);
        sourceCode.setFont( outputFont );
        input.add( new JScrollPane( sourceCode ),
          BorderLayout.CENTER );
        sourceCode.select(0,sourceCode.getText().length());
        JPanel namePanel = new JPanel(new BorderLayout(pad,pad));
        name = new JTextField(15);
        name.setToolTipText("Name of the public class");
        namePanel.add( name, BorderLayout.CENTER );
        namePanel.add( new JLabel("Class name"), BorderLayout.WEST );
        input.add( namePanel, BorderLayout.NORTH );
        compile = new JButton( "Compile" );
        compile.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              (new SourceCompilation()).execute();
        input.add( compile, BorderLayout.SOUTH );
        this.add( input, BorderLayout.CENTER );
        output = new JTextArea("", 5, 40);
        output.setFont( outputFont );
        output.setEditable(false);
        this.add( new JScrollPane( output ), BorderLayout.SOUTH );
      /** Compile the code in the source input area. */
      public String compileCode() {
        output.setText( "Compiling.." );
        enableComponents(false);
        String compResult = null;
        if (compiler==null) {
          compiler = ToolProvider.getSystemJavaCompiler();
        if ( compiler!=null ) {
          String code = sourceCode.getText();
          String sourceName = name.getText().trim();
          if ( sourceName.toLowerCase().endsWith(".java") ) {
            sourceName = sourceName.substring(
              0,sourceName.length()-5 );
          JavaSourceFromString javaString = new JavaSourceFromString(
            sourceName,
            code);
          ArrayList<JavaSourceFromString> al =
            new ArrayList<JavaSourceFromString>();
          al.add( javaString );
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          OutputStreamWriter osw = new OutputStreamWriter( baos );
          JavaCompiler.CompilationTask task = compiler.getTask(
            osw,
            null,
            null,
            null,
            null,
            al);
          boolean success = task.call();
          output.setText( baos.toString().replaceAll("\t", "  ") );
          compResult = "Compiled without errors: " + success;
          output.append( compResult );
          output.setCaretPosition(0);
        } else {
          output.setText( "No compilation possible - sorry!" );
          JOptionPane.showMessageDialog(this,
            "No compiler is available to this runtime!",
            "Compiler not found",
            JOptionPane.ERROR_MESSAGE
          System.exit(-1);
        return compResult;
      /** Set the main GUI input components enabled
      according to the enable flag. */
      public void enableComponents(boolean enable) {
        compile.setEnabled(enable);
        name.setEnabled(enable);
        sourceCode.setEnabled(enable);
      public static void main(String[] args) throws Exception {
        Runnable r = new Runnable() {
          public void run() {
            JFrame f = new JFrame("SSCCE text based compiler");
            f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            GuiCompiler compilerPane = new GuiCompiler();
            compilerPane.initGui();
            f.getContentPane().add(compilerPane);
            f.pack();
            f.setMinimumSize( f.getSize() );
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        EventQueue.invokeLater(r);
    * A file object used to represent source coming from a string.
    * This example is from the JavaDocs for JavaCompiler.
    class JavaSourceFromString extends SimpleJavaFileObject {
      * The source code of this "file".
      final String code;
      * Constructs a new JavaSourceFromString.
      * @param name the name of the compilation unit represented
        by this file object
      * @param code the source code for the compilation unit
        represented by this file object
      JavaSourceFromString(String name, String code) {
        super(URI.create(
          "string:///" +
          name.replace('.','/') +
          Kind.SOURCE.extension),
          Kind.SOURCE);
        this.code = code;
      @Override
      public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return code;
    }Edit 1:
    Added..
            f.setMinimumSize( f.getSize() );Edited by: AndrewThompson64 on Jun 13, 2008 12:24 PM
    Edited by: AndrewThompson64 on Jun 23, 2008 5:54 AM

    kevjava wrote: Some things that I think would be useful:
    Suggestions reordered to suit my reply..
    kevjava wrote: 2. Line numbering, and/or a line counter so you can see how much scrolling you're going to be imposing on the forum readers.
    Good idea, and since the line count is only a handful of lines of code to implement, I took that option. See the [line count|http://pscode.org/stbc/help.html#linecount] section of the (new) [STBC Help|http://pscode.org/stbc/help.html] page for more details. (Insert plaintiff whining about the arbitrary limits set - here).
    I considered adding line length checking, but the [Text Width Checker|http://pscode.org/twc/] ('sold separately') already has that covered, and I would prefer to keep this tool more specific to compilation, which leads me to..
    kevjava wrote: 1. A button to run the code, to see that it demonstrates the problem that you wish for the forum to solve...
    Interesting idea, but I think that is better suited to a more full blown (but still relatively simple) GUId compiler. I am not fully decided that running a class is unsuited to STBC, but I am more likely to implement a clickable list of compilation errors, than a 'run' button.
    On the other hand I am thinking the clickable error list is also better suited to an altogether more abled compiler, so don't hold your breath to see either in the STBC.
    You might note I have not bothered to update the screenshots to show the line count label. That is because I am still considering error lists and running code, and open to further suggestion (not because I am just slack!). If the screenshots update to include the line count but nothing else, take that as a sign. ;-)
    Thanks for your ideas. The line count alone is worth a few Dukes.

  • -Xlint warning when compiling with command prompt.

    1 of the method i write in the program has a compilation warning when compiling with command prompt. When i compile the codes with the application i used to write the program has no error at all. Below is my code:
    private static ArrayList readNum(String NumFile)
    ArrayList key = new ArrayList();
    String keyAttributes = readInput(NumFile);
    StringTokenizer stk = new StringTokenizer(keyAttributes);
    while(stk.hasMoreTokens())
    key.add(stk.nextToken());
    return key;
    When i javac the program with -X;int, this errror occured:
    warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
    key.add(stk.nextToken());
    ^
    1 warning
    Anyidea how to solve this problem? Thanks for the help.

    A quick google for that message would have told you that you're not using generics and the compiler complains about that.
    Google for "Java Generics" to find out what all the fuss is about.

  • Simple list won't compile with -template=wholeclass

    I have narrowed this down to a simple program:
    #include <rw/cstring.h>
    #include <list>
    void dave()
    std::list<RWCString> daveStr;
    When I compile with:
    CC -template=wholeclass -library=rwtools7_std -g -c Dave.cc
    I get errors:
    /opt/SUNWspro/WS6U2/include/CC/Cstd/./list.cc, line 351:Error:
    Too many arguments in call to "std::list<RWCString, std::allocator<RWCString>>::
    __adjacent_merge(std::list<RWCString, std::allocator<RWCString>>::iterator,
    std::list<RWCString, std::allocator<RWCstring>>::iterator, std::list<RWCString,
    std::allocator<RWCString>>::iterator)
    /opt/SUNWspro/WS6U2/include/CC/Cstd/./list, line 465: Where: While instantiating
    "std::list<RWCString, std::allocator<RWCString>>sort(bool(*)(const RWCString&,
    const RWCString &))
    /opt/SUNWSpro/WS6U2/include/CC/Cstd/./list, line 465: Where: Instantiated from
    non-template code.
    1 Error(s) detected.
    The temporary work-around is to not use- template=wholeclass, but isn't
    this something that should work. Has anyone else encountered this?

    Hello There,
    111685-0
    I compiled your testcase on our machine that has 111685-04 patch
    installed for C++ workshop 6 Update 2. I do not get any error message. It compiles fine.
    % CC6u2 -V -template=wholeclass -library=rwtools7_std -g -c template.wholeclass.cpp
    CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-04 2001/12/13
    ccfe: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-04 2001/12/13
    Please check your system if it requires to install patch.
    ....jagruti
    Developers Technical Support
    Sun Microsystems, http://www.sun.com/developers/support

  • I'm compiling with 1.5 but java is looking for 1.4 classes,why?

    Hello all,
    I need to compile my project with 1.5 and I have set everything correctly in my ant build script(I think) but I am getting the famous error:
    [javac] class file has wrong version 49.0, should be 48.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    I have been searching on Google for a couple of hours and read the whole thread on this that was locked. Most people with this error seem to want to compile with 1.4 but I'm compiling with 1.5 and for some reason it things I'm doing it with 1.4.
    If I do java -version i see 1.5, If I put -verbose when calling my build script I see 1.5 as the java version.
    I have tried with:
    jrockit_150_12
    jdk150_12

    jmejiaa wrote:
    Hello all,
    I need to compile my project with 1.5 and I have set everything correctly in my ant build script(I think) but I am getting the famous error:
    [javac] class file has wrong version 49.0, should be 48.0
    [javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
    I have been searching on Google for a couple of hours and read the whole thread on this that was locked. Most people with this error seem to want to compile with 1.4 but I'm compiling with 1.5 and for some reason it things I'm doing it with 1.4.
    Easiest explanation would be because you are.
    Actually that is the only explanation.
    If I do java -version i see 1.5, If I put -verbose when calling my build script I see 1.5 as the java version. You can find the 1.4 version and remove it or change the directory.
    One cause of this can because ant runs with a version but there are ways to make it use another one.
    And normally you don't run ant with java but rather via a script file and that specifies the java (for ant.)

Maybe you are looking for

  • Is there a way to fix an iPod touch 4G home button that isn't stuck but just doesn't work?

    A couple weeks ago my home button got stuck. To fix it I found this video http://www.youtube.com/watch?v=yBfhCmq9VkA&list=WL429346A18D0B1E65 to help me out. The second option of using the charger ended up working, thus making the button work again. I

  • Preview in browser not working since update

    Since I updated to Muse cc 2014 the program locks when I try to preview in browser. A massage stating that "Adobe muse CC has encountered an error and will exit" appears followed by "pendingProcessInfo not found in pending processes", I then have to

  • How to import ipod library

    I had a pc with itunes and I buy an ibook. My question are how import my itunes library from my pc to my ibook or how import my library in my ipod to my ibook. Thanks for your help.

  • How to display document from external archive via archivelink?

    Hi, I would like to display in SAP (via ArchiveLink) scanned document which was stored in an external archive (FileNet). The archive system is connected to SAP via ArchiveLink. However the scanned document isn't stored in the archive system via SAP s

  • Details on Exit plug

    Hi, I am working on Webdynpro for ABAP and would like to implement the Exit Plug functionality. Can any one provide me one sample program for my reference, so that it would be easy for my development. Regards, Ramya.