I'm trying to compile a simple hello world program, but then I get the following error:
/usr/share/haxe/std/haxe/EnumTools.hx:50: characters 44-51 : Type name Main is redefined from module Main
Any ideas?
It was a problem that I had two .hx files(which both had the same Main class) in the same directory, when I tried to compile the error was not so clear
Related
Currently, I am working on programming Embedded C in Linux environment. I am trying to read input data from a joystick.
Before, when I created a header file joystick.h with all definitions and I initialized the joystick inside the main function (the header file is not compiled). Everything was okay and smooth.
However, when I refactored the code by putting initialization in joystick.c (which included joystick.h) and call the initialization function in main() from joystick.h. There was an error "fatal error: asm/types.h: No such file or directory". This error happened after creating joystick.c file because the joystick.c was added to Makefile to compile.
I tried several ways to fix this such as:
add "export ARCH=x86_64"
change asm -> asm-generic
Those did not work.
So how can I fix this error?
Best regards, Huy Nguyen.
Edit: this error occurs only when using emacs haskell mode and intero mode (C-c C-l to load into ghci). It works in command line using stack ghc Log.hs LogAnalysis.hs.
I'm learning Haskell through CIS 194 (Spring 2013), and am running into this problem when doing homework 2. The homework folder is very simple:
homework2
|-- LogAnalysis.hs
|-- Log.hs
|-- error.log
|-- sample.log
Some data types are defined in Log.hs, and need to be imported into LogAnalysis.hs, which is the file I need to work on. The first few lines in LogAnalysis.hs are like this:
{-# OPTIONS_GHC -Wall #-}
module LogAnalysis where
import Log
-- Exercise 1: parse an individual message
...
However, I got error message like this in my emacs using haskell mode with intero:
error:
Could not find module 'Log'
Use -v to see a list of the files searched for.
(Hit 'C-c C-r' in the Haskell buffer to apply suggestions.)
Same message appears when using 'C-c C-l' to load to ghci within emacs.
But this error doesn't appear when loading LogAnalysis.hs in command line using stack ghci, the message is instead:
Prelude> :l LogAnalysis.hs
[1 of 2] Compiling Log ( Log.hs, interpreted )
[2 of 2] Compiling LogAnalysis ( LogAnalysis.hs, interpreted )
Ok, two modules loaded.
*LogAnalysis>
So I'm guessing this error has something to do with my emacs' setup of haskell mode and intero mode, but couldn't find any available solution yet.
Thanks for reading this question, your help will be appreciated!
It seems that intero needs a package.yaml and a stack.yaml in order to locate your source files. You can just run stack init or stack new to auto matically generate these project files.
I met this problem several times. The above method solved my problem on my Windows and Fedora, so I hope this will help you.
With the help of Krantz's answer and some more reading, the problem is solved by creating a new project with stack so intero knows the location of my source files.
Thus this problem is caused by intero's not knowing where to look for local modules when in intero-global-mode in emacs.
Here I'll write my own answer here to expand Krantz's answer a little more, and to document the process of solving this problem as a beginner to Haskell:
For intero to be able to import local modules, we should avoid using intero-global-mode and instead creating a local project (which in hindsight makes more sense to me).
So in the case of this Homework 2, instead of moving files to a homework folder as described in the question, I'll stack new homework2, and move the sources files into homework2\src. Then when using emacs to load LogAnalysis.hs, instead of this previous message I got in *intero:global-project::repl*:
Loaded GHCi configuration from /Users/[username]/.stack/global-project/.stack-work/intero/intero-[script]
and error message when loading LogAnalysis.hs, I'm now able to get:
Loaded GHCi configuration from /path/to/homework2/.stack-work/intero/intero-[script]
in *intero:homework2:homework2:repl*. And using C-c C-l to load LogAnalysis.hs now gets:
[2 of 2] Compiling LogAnalysis ( /path/to/homework2/src/LogAnalysis.hs, interpreted ) [flags changed]
Ok, two modules loaded.
So problem solved.
So, I'm trying to use the Plugins package to dynamically load a haskell function from a source file. The source file depends on a package foo with module Foo.Bar. I'm running my project in a Cabal sandbox, where I have foo installed. Both my main program, and the module I'm loading with plugins, depend on foo. I always get one of the following two errors:
When I have foo installed in ~/.cabal, I get the error:
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
aizmvszmaizmlibzm0zi1_FooziBar_zdfTypeableBazzuds2_closure
whilst processing object file
/home/joey/.cabal/lib/foo-0.1/ghc-7.6.3/HSfoo-0.1.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
When I don't have it installed in ~/.cabal, I get a standard "module not found" error. And when I don't have it installed in my sandbox, I get the same module not found error trying to compile my main program code.
The plugins documentation is scarce at best. Any thoughts on how to solve this?
I got this working by using System.Plugins.Make to actually do the compliation, instead of relying on pre-existing object files. Not a complete solution, doesn't explain the problem, but it works for me for now.
I'm trying to compile a program which uses the alglib function pearsoncorr2.
Unfortunately I always get compilation errors like the following:
undefined reference to `alglib::real_1d_array::real_1d_array()'
I know that I have to compile all the dependencies of the alglib unit which contains the function I want to use. In my case it's statistics.h.
I'm including all the necessary files (ap.h, statistics.h, alglibinternal.h, alglibmisc.h, linalg.h, specialfunctions.h) when compiling my program, but still I get these undefined reference errors.
I'm using g++ on linux.
What am I doing wrong?
Thanks in advance.
You also need to include the binary part -- i.e., either the *.o files or the *.so library file -- on your final link line. So for example, you probably need to link with linalg.o .
Alglib needs to compile all 13 cpp files before using it.
I have CMakeList.txt to tare care all the dependencies for me.
I get an error message from GHCi about a "duplicate definition for symbol __module_registered", like this:
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
__module_registered
whilst processing object file
/usr/local/lib/ghc-6.2/HSfgl.o
How to fix this?
Thats is easy, probably indicates that when building a library for GHCi (HSfgl.o in the above example), you should use the -x option to ld.