EzDevInfo.com

compilation interview questions

Top compilation frequently asked interview questions

The project cannot be built until the build path errors are resolved.

While compiling an android project in eclipse 3.4.2, I am getting The project cannot be built until the build path errors are resolved.

I got a temporary solution from the blog http://www.scottdstrader.com/blog/ether_archives/000921.html

The resolution was to force a resave of the selected projects (and their .classpath files):

  1. Open the project properties
  2. Select Java Build Path > Libraries
  3. Add a new, arbitrary library (to be deleted later) > OK
  4. Wait for the workspace to refresh (or force a refresh of the project)
  5. The error(s) will go away
  6. Remove the dummy library

The only other references I could find were to make minor alterations of contents of the .classpath file.

Is there any permanent fix for this issue?


Source: (StackOverflow)

Compiling and Running Java Code in Sublime Text 2

I am trying to compile and run Java code in Sublime Text 2. Don't just tell me to do it manually in the Command Prompt. Can anyone tell me how?

Btw, I am on Windows 7...


Source: (StackOverflow)

Advertisements

How to fix error with xml2-config not found when installing PHP from sources?

When I try to install php 5.3 stable from source on Ubuntu (downloading compressed installation file from http://www.php.net/downloads.php) and I run ./configure I get this error:

configure: error: xml2-config not found. Please check your libxml2 installation.

Source: (StackOverflow)

Splitting a Clojure namespace over multiple files

Is it possible to split a Clojure namespace over multiple source files when doing ahead-of-time compilation with :gen-class? How do (:main true) and (defn- ...) come into play?


Source: (StackOverflow)

javac : command not found

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac.

Do I need to install any other package?

I have tried to locate the javac executable but i am unable to locate it.

/usr/bin/java is linked as follows:
/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

I have seen the following output by yum list installed |grep java:

java-1.6.0-openjdk.x86_64              1:1.6.0.0-1.16.b17.el5          installed
tzdata-java.x86_64                     2011b-1.el5                     installed

Source: (StackOverflow)

Infinite loop breaks method signature without compilation error [duplicate]

This question already has an answer here:

I am wondering why is the following code allowed in Java, without getting compilation error? In my opinion, this code breaks method signature by not returning any String. Could someone explain what I'm missing here?

public class Loop {

  private String withoutReturnStatement() {
    while(true) {}
  }

  public static void main(String[] a) {
    new Loop().withoutReturnStatement();
  }
}

Source: (StackOverflow)

Java compile speed vs Scala compile speed

I've been programming in Scala for a while and I like it but one thing I'm annoyed by is the time it takes to compile programs. It's seems like a small thing but with Java I could make small changes to my program, click the run button in netbeans, and BOOM, it's running, and over time compiling in scala seems to consume a lot of time. I hear that with many large projects a scripting language becomes very important because of the time compiling takes, a need that I didn't see arising when I was using Java.

But I'm coming from Java which as I understand it, is faster than any other compiled language, and is fast because of the reasons I switched to Scala(It's a very simple language).

So I wanted to ask, can I make Scala compile faster and will scalac ever be as fast as javac.


Source: (StackOverflow)

#ifdef #ifndef in Java

I doubt if there is a way to make compile-time conditions in Java like #ifdef #ifndef in C++.

My problem is that have an algorithm written in Java, and I have different running time improves to that algorithm. So I want to measure how much time I save when each improve is used.

Right now I have a set of boolean variables that are used to decide during the running time which improve should be used and which not. But even testing those variables influences the total running time.

So I want to find out a way to decide during the compilation time which parts of the program should be compiled and used.

Does someone knows a way to do it in Java. Or maybe someone knows that there is no such way (it also would be useful).


Source: (StackOverflow)

How to compile a .NET application to native code?

If I want to run a .NET application in a machine where the .NET framework is not available; Is there any way to compile the application to native code?


Source: (StackOverflow)

How to compile/install node.js(could not configure a cxx compiler!) (Ubuntu).

How can I compile/install node.js on Ubuntu? It failed with an error about cxx compiler.


Source: (StackOverflow)

Why doesn't the JVM cache JIT compiled code?

The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times. The question is, why isn't this compiled code cached to disk for use during subsequent uses of the same function/class. As it stands, every time a program is executed, the JIT compiler kicks in afresh, rather than using a pre-compiled version of the code. Wouldn't adding this feature add a significant boost to the initial run time of the program, when the bytecode is essentially being interpreted?


Source: (StackOverflow)

AngularJS - Compiling dynamic HTML strings from database

The Situation

Nested within our Angular app is a directive called Page, backed by a controller, which contains a div with an ng-bind-html-unsafe attribute. This is assigned to a $scope var called 'pageContent'. This var gets assigned dynamically generated HTML from a database. When the user flips to the next page, a called to the DB is made, and the pageContent var is set to this new HTML, which gets rendered onscreen through ng-bind-html-unsafe. Here's the code:

Page directive

angular.module('myApp.directives')
    .directive('myPage', function ($compile) {

        return {
            templateUrl: 'page.html',
            restrict: 'E',
            compile: function compile(element, attrs, transclude) {
                // does nothing currently
                return {
                    pre: function preLink(scope, element, attrs, controller) {
                        // does nothing currently
                    },
                    post: function postLink(scope, element, attrs, controller) {
                        // does nothing currently
                    }
                }
            }
        };
    });

Page directive's template ("page.html" from the templateUrl property above)

<div ng-controller="PageCtrl" >
   ...
   <!-- dynamic page content written into the div below -->
   <div ng-bind-html-unsafe="pageContent" >
   ...
</div>

Page controller

angular.module('myApp')
  .controller('PageCtrl', function ($scope) {

        $scope.pageContent = '';

        $scope.$on( "receivedPageContent", function(event, args) {
            console.log( 'new page content received after DB call' );
            $scope.pageContent = args.htmlStrFromDB;
        });

});

That works. We see the page's HTML from the DB rendered nicely in the browser. When the user flips to the next page, we see the next page's content, and so on. So far so good.

The Problem

The problem here is that we want to have interactive content inside of a page's content. For instance, the HTML may contain a thumbnail image where, when the user clicks on it, Angular should do something awesome, such as displaying a pop-up modal window. I've placed Angular method calls (ng-click) in the HTML strings in our database, but of course Angular isn't going to recognize either method calls or directives unless it somehow parses the HTML string, recognizes them and compiles them.

In our DB

Content for Page 1:

<p>Here's a cool pic of a lion. <img src="lion.png" ng-click="doSomethingAwesone('lion', 'showImage')" > Click on him to see a large image.</p>

Content for Page 2:

<p>Here's a snake. <img src="snake.png" ng-click="doSomethingAwesone('snake', 'playSound')" >Click to make him hiss.</p>

Back in the Page controller, we then add the corresponding $scope function:

Page controller

$scope.doSomethingAwesome = function( id, action ) {
    console.log( "Going to do " + action + " with "+ id );
}

I can't figure out how to call that 'doSomethingAwesome' method from within the HTML string from the DB. I realize Angular has to parse the HTML string somehow, but how? I've read vague mumblings about the $compile service, and copied and pasted some examples, but nothing works. Also, most examples show dynamic content only getting set during the linking phase of the directive. We would want Page to stay alive throughout the life of the app. It constantly receives, compiles and displays new content as the user flips through pages.

In an abstract sense, I guess you could say we are trying to dynamically nest chunks of Angular within an Angular app, and need to be able to swap them in and out.

I've read various bits of Angular documentation multiple times, as well as all sorts of blog posts, and JS Fiddled with people's code. I don't know whether I'm completely misunderstanding Angular, or just missing something simple, or maybe I'm slow. In any case, I could use some advice.


Source: (StackOverflow)

Compiling a java program into an executable [duplicate]

Possible Duplicate:
How do I create an .exe for a Java program?

I've just made a simple program with eclipse and I want to compile it into an executable, but simply can't seem to find out how to do it. Please help.


Source: (StackOverflow)

What is the purpose of the "Prefer 32-bit" setting in Visual Studio 2012 and how does it actually work?

Enter image description here

It is unclear to me how the compiler will automatically know to compile for 64-bit when it needs to. How does it know when it can confidently target 32-bit?

I am mainly curious about how the compiler knows which architecture to target when compiling. Does it analyze the code and make a decision based on what it finds?


Source: (StackOverflow)

Is it feasible to compile Python to machine code?

How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code?

Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would need to be compiled (and linked in) too.

Also, you would need to bundle the Python interpreter if you wanted to do dynamic evaluation of expressions, but perhaps a subset of Python that didn't allow this would still be useful.

Would it provide any speed and/or memory usage advantages? Presumably the startup time of the Python interpreter would be eliminated (although shared libraries would still need loading at startup).


Source: (StackOverflow)