How to compile a C extension as part of a ruby gem with mkmf on Mac OS X? - c

I am trying to create a gem that wraps libpuzzle, but cannot figure out this flat_namespace issue:
--- personal/sayzame ‹master* M⁇› » gem build sayzame.gemspec && gem install sayzame-0.0.1.gem
Successfully built RubyGem
Name: sayzame
Version: 0.0.1
File: sayzame-0.0.1.gem
Building native extensions. This could take a while...
Successfully installed sayzame-0.0.1
1 gem installed
--- personal/sayzame ‹master* M⁇› » pry -rsayzame -Ilib
[1] pry(main)> Sayzame.compare_images :a, :b
dyld: lazy symbol binding failed: Symbol not found: _puzzle_init_dvec
Referenced from: /usr/local/lib/libpuzzle.dylib
Expected in: flat namespace
dyld: Symbol not found: _puzzle_init_dvec
Referenced from: /usr/local/lib/libpuzzle.dylib
Expected in: flat namespace
[1] 56394 trace trap pry -rsayzame -Ilib
My full source code here: https://github.com/neezer/sayzame
I'm fairly sure the problem is in my ext/puzzle/extconf.rb file, in that I am not linking the library correctly. I have already posted on ffi/ffi's issue tracker about it and followed up on those two leads with no success.
I would really appreciate any and all help here; been banging my head against the wall for quite sometime on this.
Possibly related:
- https://groups.google.com/d/msg/picky-ruby/8kuG8FkATgU/89JLc6U7SrcJ

Related

Cycle in dependencies between targets 'FBReactNativeSpec' and 'Yoga'; building could produce unreliable results

Whenever I run "react-native run-ios" I'm getting the following build error
error: Cycle in dependencies between targets 'FBReactNativeSpec' and
'Yoga'; building could produce unreliable results. Cycle path:
FBReactNativeSpec → Folly → glog → YogaKit → Yoga → FBReactNativeSpec
Cycle details: → Target 'FBReactNativeSpec' has target dependency on
Target 'Folly' → Target 'Folly' has target dependency on Target 'glog'
→ Target 'glog' has compile command with input
'/Users/ajayhg/Myproj/ios/Pods/Target Support Files/glog/glog-dummy.m'
○ That command depends on command in Target 'YogaKit': script phase
“Copy generated compatibility header” → Target 'YogaKit' has target
dependency on Target 'Yoga' → Target 'Yoga' has compile command with
input '/Users/ajayhg/Myproj/ios/Pods/Target Support
Files/Yoga/Yoga-dummy.m'
how to resolve this?
I solved the problem by doing ⌘+Shift+K and rebuilding.
I have exact same problem on our app, but unfortunately no solution yet.
Known workaronds are:
Switch to legacy build system. It doesn't react on those "fake" cycles
Clean and rebuild usually helps. If not, then try to clean and reinstal cocoapods.
Relevant thread here.
It appears as though Firebase adds a script phase in an order that creates a dependency loop. You can fix it (laboriously, after every pod install) by going to XCode > Pods (in the left bar) > FBReactNativeSpec and moving [CP-User] Generate Specs up above the Headers script(s).

RIOT OS Gpio Example

I have to work with RIOT OS and currently I'm testing out how everything
works (or not work).
Info: RIOT OS is a IOT OS which run on mircocontrollers and arms.
I develop under Debian with Eclispe, the develop environment was setup after the GitHub Guide from RIOT. The Guide
The hello world example works for me without problems.
Now I want to load some of the RIOT modules and then I get errors.
That's what I did so far.
I created a new folder for my project, copy the hello-world example and
adjust the makefile.
Then I adjust the riot project properties like in the guide, just for my example.
Created the new symbol and include xml and imported them.
Re-indexed the riot project
Changed the basic hello world code with my example code.
Try to build it....
This is my example main, it doesn't do much, just init a gpio pin.
#include <stdio.h>
#include "periph/gpio.h"
int main(void)
{
gpio_t pin = GPIO(1,22);
gpio_init(pin,GPIO_OUT);
return 0;
}
And this is the makefile for it
# name of your application
APPLICATION = test
# If no BOARD is found in the environment, use this default:
BOARD ?= nucleo-f303
# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..
# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1
FEATURES_REQUIRED = periph_gpio
include $(RIOTBASE)/Makefile.include
By building the project I get following errors:
In english it would be something like:
- the rule for target "path" failed.
- the rule for target "link" failed.
- make: [link] error 2
- make(1): ["path/main.o"] error 1
This is the part in the riot makefile where the error happen.
Its exactly the same in both file (Makefile.include and Makefile.base).
I hope anybody can me explain what I did wrong or where are my mistakes.
EDIT:
The problem was GPIO() was wrong... its called GPIO_PIN() thats cause the error.

XLConnect, rJava and package building

I am writing a function that i want to include in a user-defined package (MYPACKAGE). The function is a follows:
readSchedule <- function(FILE){
WB = loadWorkbook(FILE)
WS= readWorksheet(WB, sheet = 'Sheet1',header = TRUE)
return(WS)
}
where FILE is the name of the Excel file i want to read. When writing this function, I want it to import XLConnect, since that is the package it uses. I placed header code defining the function:
#param FILE Excel file
#return Excel data
#export
#import XLConnect
I have also added import(XLConnect) to the NAMESPACE and the DESCRIPTION file of MYPACKAGE. The package builds fine (or at least at first cut it appears to build OK) but when i run "Check Package" it fails and gives me the following error:
* installing *source* package 'MYPACKAGE' ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
I have the correct version of Java and can load rJava just fine. i've tried importing rJava (similar to XLConnect) but i get the same error. Below is my sessionInfo:
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MYPACKAGE
loaded via a namespace (and not attached):
[1] chron_2.3-45 data.table_1.9.4 digest_0.6.8 lubridate_1.3.3 memoise_0.2.1 plyr_1.8.1
[7] Rcpp_0.11.1 reshape2_1.4 rJava_0.9-6 stringr_0.6.2 tools_3.1.2 XLConnect_0.2-7
It looks like you are building your package on a Windows 64-bit machine with a 64-bit version of Java installed. When checking your package using R CMD check, R by default also attempts to check your package on other sub-architectures (i386, 32-bit) which in your case would in addition require a 32-bit installation of Java.
If you want to check your package also for i386 you may just additionally install Java 32-bit. The other option is to pass the option --no-multiarch to your R CMD check call, e.g. R CMD check --no-multiarch MYPACKAGE.

How to compile WPF IronPython project to exe

I've seen many questions in this forum which are questions of how to fix a problems of compiling IronPython WPF to exe.
But the problem is that I haven't seen any guide Step-by-step of how to compile my project.
I understood it includes using the clr module.
I've 6 files:
Window.py, Window.xaml.
Window1.py, Window1.xaml.
Window2.py, Window2.xaml.
That's all the files
Thanks
((irrelevant: Update- 3 hours later:
I've started using SharpDevelop and when I run it through the software itself it can be run. However , when I try to run this through the .exe file in the project's folder it doesn't work... ))
Update 2 - SharpDevelop created an exe file which works but the problem is it didn't encrypt my xaml to dll ..
Have you tried the script from this thread: Ironpython 2.6 .py -> .exe
Supposedly it includes wpf support:
#!/usr/bin/env python
# CompileToStandalone, a Python to .NET ILR compiler which produces standalone binaries
# (C) 2012 Niall Douglas http://www.nedproductions.biz/
# Created: March 2012
import modulefinder, sys, os, subprocess, _winreg
if len(sys.argv)<2:
print("Usage: CompileEverythingToILR.py <source py> [-outdir=<dest dir>]")
sys.exit(0)
if sys.platform=="cli":
print("ERROR: IronPython's ModuleFinder currently doesn't work, so run me under CPython please")
sys.exit(1)
sourcepath=sys.argv[1]
destpath=sys.argv[2][8:] if len(sys.argv)==3 else os.path.dirname(sys.argv[0])
ironpythonpath=None
try:
try:
keyh=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\IronPython\\2.7\\InstallPath")
ironpythonpath=_winreg.QueryValue(keyh, None)
except Exception as e:
try:
keyh=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\IronPython\\2.7\\InstallPath")
ironpythonpath=_winreg.QueryValue(keyh, "")
except Exception as e:
pass
finally:
if ironpythonpath is not None:
_winreg.CloseKey(keyh)
print("IronPython found at "+ironpythonpath)
else:
raise Exception("Cannot find IronPython in the registry")
# What we do now is to load the python source but against the customised IronPython runtime
# library which has been hacked to work with IronPython. This spits out the right set of
# modules mostly, but we include the main python's site-packages in order to resolve any
# third party packages
print("Scanning '"+sourcepath+"' for dependencies and outputting into '"+destpath+"' ...")
searchpaths=[".", ironpythonpath+os.sep+"Lib"]
searchpaths+=[x for x in sys.path if 'site-packages' in x]
finder=modulefinder.ModuleFinder(searchpaths)
finder.run_script(sourcepath)
print(finder.report())
modules=[]
badmodules=finder.badmodules.keys()
for name, mod in finder.modules.iteritems():
path=mod.__file__
# Ignore internal modules
if path is None: continue
# Ignore DLL internal modules
#if '\\DLLs\\' in path: continue
# Watch out for C modules
if os.path.splitext(path)[1]=='.pyd':
print("WARNING: I don't support handling C modules at '"+path+"'")
badmodules.append(name)
continue
modules.append((name, os.path.abspath(path)))
modules.sort()
print("Modules not imported due to not found, error or being a C module:")
print("\n".join(badmodules))
raw_input("\nPress Return if you are happy with these missing modules ...")
with open(destpath+os.sep+"files.txt", "w") as oh:
oh.writelines([x[1]+'\n' for x in modules])
cmd='ipy64 '+destpath+os.sep+'pyc.py /main:"'+os.path.abspath(sourcepath)+'" /out:'+os.path.splitext(os.path.basename(sourcepath))[0]+' /target:exe /standalone /platform:x86 /files:'+destpath+os.sep+'files.txt'
print(cmd)
cwd=os.getcwd()
try:
os.chdir(destpath)
retcode=subprocess.call(cmd, shell=True)
finally:
os.chdir(cwd)
sys.exit(retcode)

Including Agilent Drivers in Ansi-C VS2010 Project results in error LNK2001

I am unable to resolve a linker error
my projects includes in one of its c files:
#include "../bin/AgN6700/agN6700.h"
#pragma comment(lib, "bin/AgN6700/agN6700.lib")
This is a adaption to a powersupply.
This adaption has several dependencies.
76 symbols fail to link.
8 are defined in the ivi.h
76 are defined in the visa.h
I have lib files for both of them on my machine in the folder:
C:\Program Files (x86)\National Instruments\Shared\CVI\ExtLib\msvc
So i added this folder to the library entrie in the VS2010 Project.
What is going wrong here? How can i investigate and solve this issue?
The full list of LNK2001 errors:
agN6700.lib(agn6700.c) : error LNK2001: ... Symbol "...".
_viOpen#20
_viClose#4
_viSetAttribute#12
_viRead#16
_viSetBuf#12
_viPrintf
_viScanf
_viQueryf
_Ivi_DefaultCheckCallbackViInt32#16
_Ivi_DefaultCheckCallbackViReal64#20
_Ivi_SpecificDriverNew#12
_Ivi_Dispose#4
_Ivi_SetAttributeViInt32#20
_Ivi_SetAttributeViReal64#24
_Ivi_SetAttributeViString#20
_Ivi_SetAttributeViBoolean#20
_Ivi_SetAttributeViSession#20
_Ivi_SetAttributeViAddr#20
_Ivi_CheckAttributeViInt32#20
_Ivi_CheckAttributeViReal64#24
_Ivi_CheckAttributeViString#20
_Ivi_CheckAttributeViBoolean#20
_Ivi_CheckAttributeViSession#20
_Ivi_GetAttributeViInt32#20
_Ivi_GetAttributeViReal64#20
_Ivi_GetAttributeViString#24
_Ivi_GetAttributeViBoolean#20
_Ivi_GetAttributeViSession#20
_Ivi_GetAttributeViAddr#20
_Ivi_AddAttributeViInt32#32
_Ivi_AddAttributeViReal64#40
_Ivi_AddAttributeViString#28
_Ivi_AddAttributeViBoolean#28
_Ivi_AddAttributeViAddr#28
_Ivi_SetAttrReadCallbackViString#12
_Ivi_SetAttrCheckCallbackViInt32#12
_Ivi_SetAttrCheckCallbackViReal64#12
_Ivi_SetAttrCheckCallbackViBoolean#12
_Ivi_SetAttrCoerceCallbackViReal64#12
_Ivi_InvalidateAttribute#12
_Ivi_InvalidateAllAttributes#4
_Ivi_NeedToCheckStatus#4
_Ivi_SetNeedToCheckStatus#8
_Ivi_BuildChannelTable#16
_Ivi_CoerceChannelName#12
_Ivi_GetNthChannelString#12
_Ivi_SetErrorInfo#20
_Ivi_GetErrorInfo#16
_Ivi_ClearErrorInfo#4
_Ivi_ParamPositionError#4
_Ivi_LockSession#8
_Ivi_UnlockSession#8
_Ivi_IOSession#4
_Ivi_RangeChecking#4
_Ivi_QueryInstrStatus#4
_Ivi_Simulating#4
_Ivi_GetStringFromTable#12
_Ivi_GetValueFromTable#12
_Ivi_GetAttrRangeTable#16
_Ivi_GetViInt32EntryFromValue#32
_Ivi_GetViInt32EntryFromString#28
_Ivi_Alloc#12
_Ivi_Free#8
_Ivi_SetValInStringCallback#12
_Ivi_GetSpecificDriverStatusDesc#16
_Ivi_CompareWithPrecision#24
_Ivi_WriteInstrData#8
_Ivi_ReadInstrData#16
_Ivi_GetInfoFromResourceName#20
_Ivi_GetNextCoercionString#12
_Ivi_GetNextInterchangeCheckString#12
_Ivi_ResetInterchangeCheck#4
_Ivi_ClearInterchangeWarnings#4
_Ivi_GetAttributeFlags#12
_Ivi_SetAttributeFlags#12
_Ivi_ApplyDefaultSetup#4
It seems i misunderstood how lib files are included in the buildprocess.
The solution is to supply the linker with additional dependencies via the project properties.
This is illustrated in this stackoverflow post.

Resources