life ideas

October 12, 2007

海归论坛 :: 阅读主题 – [分享]对冲基金精英榜(Elite of the Hedge Fund)

Filed under: Uncategorized — manoftoday @ 8:44 pm

 

english version:

http://nymag.com/news/features/2007/hedgefunds/30342/

2007年07月31日 《当代金融家》
  乔治·索罗斯、JulianRobertson、Michael Steinhardt、Stanley Druckenmiller、Louis Bacon、Paul Tudor Jones二世、Bruce Kovner、Arthur Samberg等人都是对冲基金领域的传奇英雄。他们并不会在接下来的文章中露面,因为他们都已功成名就,不需要再证明任何东西了。本文对10位熟悉对冲基金的人士进行匿名调查,基于调查结果,对6个组别的当今最杰出的对冲基金经理进行排名。10位接受调研的人士中有5位本身就是对冲基金经理,2位在著名的投资银行中从事与冲基金相关的业务,1位是投资人,其余两位是财经记者。
笑傲江湖,领袖群伦型
  ◎ Steve Cohen /SAC投资顾问(SAC Capital Advisors)
  规模:120亿美元类型:交易员
  地址:Stamford,康涅狄格州
  被议论最多的对冲基金经理。在康涅狄格州的格林威治拥有一所32000平方英尺的大房子,其建筑占地14英亩。房屋本身堪称当代建筑的伟大艺术品。2006年10月,他花了6350万美元从娱乐业巨子、梦工场(DreamWorks)共同创始人大卫o格芬(David Geffen)手里买下当代艺术大师威廉o德o库宁(Willemde Kooning)的名画Police Gazette。他的个人净资产估计高达30亿美元。老手评价:“出身草根,是位了不起的交易者,异常强悍。”
  对冲基金投资人评价:“此公卵翼下造就的那些投资组合经理将是对冲基金界的下一拨明星。”新手评价:“以交易量而言,可能是世界上最大的交易商。而且公司中绝大多数资产是他自己的!”
  ◎ Stephen Feinberg /Cerberus资本
  规模:191.5亿美元
  类型:危机投资者
  地址:曼哈顿
  在“垃圾债券大王”米尔肯(MichaelMilken)麾下,供职于DrexelBurnhamLambert。 “秃鹫投资者”中的顶级高手。刚刚从奔驰手上买下克莱斯勒汽车公司。喜欢共和党:美国前副总统丹o奎尔(DanQuayle)就在Cerberus的团队中,前财政部长斯诺(John Snow)任公司董事长。老手评价:“最伟大的积极主义投资者之一。”
  对冲基金投资人评价:“一个安静的家伙,几乎不在任何社交场合露面的。简直是个投资机器。不露声 色地将一家危机投资公司变身为专门从事收购的公司。”
  新手:“危机投资界、中级市场以及私募交易界的顶尖人物。”
  ◎ David Tepper /Appaloosa 管理公司
  规模:53亿美元
  类型:危机投资者
  地址:Chatham,新泽西
  在高盛主管垃圾债券业务。1993年,步众多前高盛同事后尘,创办Appaloosa。和 Cerberus一样,在汽车行业寻找机会。与Cerberus在德尔福(Delphi)汽车配件公司一案中合作。净资产约15亿美元。老手评价:“伟大的危机投资者,同样了不起的积极主义投资者。”
  对冲基金投资人评价:“大手笔,但很冒险。给卡耐基梅隆大学商学院捐了不少钱,以至于商学院就用他的名字命名。”
  新手评价:“过去10年中最卓越的危机投资家。”
  ◎ Eddie Lampert /ESL投资
  规模:180亿美元
  类型:拣股者
  地址:康涅狄格的格林威治
  曾经被绑架。被誉为他那一代人中最伟大的投资者,积极主义投资者的领军人物。专注于零售业,拥有西尔斯百货(西尔斯拥有卡玛特连锁超市)和全美最大的汽车零售连锁AutoNation。净资产约38亿美元,是康涅狄格州首富。
  老手评价:“在管理他投资的公司时亲力亲为、兢兢业业。没什么特别的嗜好,但是个了不起的人。”对冲基金投资人评价“:他正在把西尔斯变成下一个伯克夏·哈撒威(Berkshire Hathaway)。不出意外的话,将成为下一个沃伦·巴菲特。”
  新手评价:“集权掌控他投资的公司。”
  ◎ Kenneth Griffin /Citadel投资集团
  规模:135亿美元
  类型:交易员
  地址:芝加哥
  过去是最深居简出的神秘家伙。去年在出售债券为自己公司筹钱时成了媒体的红人,彼时恰逢此公从Amaranth彻底垮台中大捞了一票。以8000万美元价格从格芬手上买下现代艺术大师JasperJohns的名作False Start。净资产约17亿美元。
  老手评价:“还在哈佛念书时就开始在宿舍里从事交易。”对冲基金投资人评价:“在凡尔赛宫结的婚。”
  新手评价:“对员工期待很高的老板,风格强悍。”
  ◎ Michael Novogratz /Fortress 投资集团
  规模:46亿美元
  类型:交易员
  地址:曼哈顿
  Fortress投资集团总裁,2007年早些时候公司上市,和同事PeterBriger以及Wesley densortress一道赚了大钱。和本排行榜上许多人一样,事业是从高盛起步的。曾是美国空军直升机飞行员。净资产约23亿美元。
  新手评价:“爱上 Fortress的股价。”
奇门遁甲,神机妙算型
  ◎ James Simons /复兴科技(Renaissance Technologies)
  规模:240亿美元类型:定量投资者
  地址:纽约East Setauket
  曾是数学教授,被誉为“黑匣投资者之王”(king of black box)。黑匣投资基金的特点是运用最为玄妙的数学运算法则,由电脑操作完成大部分投资行为。最近瞄准一项1000亿美元的基金,着实令同行目瞪口呆。收取5%的管理费和 44%的提成,为业内最高,但没人对此说三道四。净资产约40亿美元。
  老手评价:“此公从来不雇用那些知道华尔街在哪里的家伙。他那里都是博士,用的算法没人能明白,但看起来效果不错。”
  对冲基金投资人评价:“和 Dalio 并称定量投资之王。”
  新手:“别的不说,在过去几年里当仁不让是薪酬最高的基金经理之一。”
  ◎ David Shaw /D.E.Shaw
  规模:263亿美元
  类型:定量投资者
  地址:曼哈顿
  帮助建立了摩根士丹利的自动交易系统。曾是计算机科学教授。1988年离职后创办自己的基金公司,从事传统统计套利(statisticalarbitrage)交易。2005年退居二线,专注于生物分子科学研究,但仍然能赚到业内最高的薪水,2005年收入约为5亿美元。净资产估计10亿美元左右。老手评价“:不声不响,这家公司已经累积了大笔资产。雇佣了离开哈佛后无所事事的拉里o萨默斯(Larry Summers,曾任美国财政部长、哈佛大学校长)。”
  新手评价:“好像是那个时代最大的对冲基金吧?”
  ◎ Clifford Asness /AQR 资本管理
  规模:95亿美元
  类型:定量投资者
  地址:康涅狄格州格林威治
  又一位离开高盛自创公司的天才。1998年与合伙人DavidKabiller,RobertKrail,JohnLiew共同创办了AQR资本管理公司。据说离开高盛的理由是高盛不愿意按业绩给他的团队成员支付合理报酬。在写作和投资方面一样有天赋。
  老手评价:“建立了伟大的事业。但是,很多人都对公司2006业绩欠佳想不通。”对冲基金投资人评价:“被邀请投资于AMG资产管理公司,大概买了25%的股份?”
  ◎ Ray Dalio /Bridgewater Associates
  规模:302亿美元
  类型:定量投资者
  地址:康涅狄格的Westport
  如果对冲基金界有一位哲学家的话,RayDalio是不二人选。“Bridgewater是一个令我们彼此命运息息相关的社区。”“钱并不会带来幸福,而追求卓越的过程却可以。”老手评价:“真正出色的定量投资者,但投资结果好坏参半。”对冲基金投资人评价:“和 Simons 并称定量投资者之王。”
  新手评价:“稳健,波澜不惊,悄无声息地建起一家财富管理巨擘。”
  ◎ Mark Carhart /高盛资产管理(Goldman Sachs Asset Management)
  规模:325亿美元
  类型:定量投资者
  地址:曼哈顿
  曾经是芝加哥大学的学者。1997年在同事CliffAsness另谋高就后,成为高盛“旗舰”全球阿尔法(GlobalAlpha)基金共同掌门人。尽管有一个好的开始,但之后的路并不平坦:2006年损失6%,整个华尔街都在传着他的流言蜚语。但2007年,这位曾经的高中数学竞赛冠军再次赢得所有人的关注。
  老手评价:“噢,2006年他真的不行过?”
好勇斗狠,快意恩仇型
  ◎ Daniel Loeb /Third Point
  规模:42亿美元
  类型:拣股者
  地址:曼哈顿
  这一行的“捣蛋分子”。花4500万美元买下了RobertA。M。Stern大厦的顶层公寓。据说是瑜伽和冲浪爱好者。
  老手评价:“大胆、直率的积极主义投资者。”
  对冲基金投资人:“总爱写些引人捧腹的邮件。你一定得读读他写给一位来自欧洲的招聘对象的邮件。Google一下好了。”
  新手评价:“纯粹的逐利者。从不惮于将无能的管理层搅得天翻地覆。”
  ◎ Thomes Hudson /海盗资本(Pirate Capital)
  规模:11亿美元
  类型:拣股者
  地址:康涅狄格州Norwalk
  因婚外恋被高盛解雇。开创海盗资本的本钱中有150万美元是自己的,其余50万是父母的。高调的行动主义者,最近的目标有汽车配件零售商 Pep Boys 和 Outback牛排餐厅的东主OSI饭店合伙公司。
  对冲基金投资人评价:“这条船可能会沉。”
  ◎ Israel Englander /千年管理(Millennium Management)
  规模:86亿美元
  类型:交易员
  地址:纽约
  犹太事业的捐赠人。付给证交会(SEC)1.8亿美元了结择时交易(markettiming)指控,其中3000万美元是自掏腰包。
  新手评价:“掉进共同基金丑闻陷阱,被逮个正着。”
  ◎ Warren Lichtenstein /Steel Partners
  规模:39亿美元
  类型:拣股者
  地址:曼哈顿
  行动主义投资者,关注美国和日本。同他的偶像CarlIcahn一道企图收购韩国烟草商 KT&G,掀起韩国历史上最大的敌意收购战事。眼下正盯着日本的札幌控股(SapporoHoldings),这家公司为全世界的寿司老饕们耳熟能详。
  老手评价:“又是一位行动主义者,但是我觉得他在BKF交易中的表现并不很好,但不可否认他仍然做过很多漂亮的交易。”
  对冲基金投资人评价:“行动主义的早期实践者,成功进军日本,现在正在向亚洲其他国家进发。”新手评价:“不怕起诉,也不怕被起诉。”
  ◎ Barry Rosenstein /JANA Partners
  规模:58亿美元
  类型:拣股者
  地址:旧金山
  曾经是美林投资银行家(竟然不是高盛出来的!)。一次风帆冲浪事故造成局部瘫痪,最后通过练瑜伽康复。引人注目的行动主义投资者。追杀那些刚愎自用的公司高管,结果被人们认为已变得像Daniel Loeb一样好勇斗狠。
  老手评价:“一位真正的行动主义者,一个聪明人。”新手:“投资回报令人印象深刻。”
不辞跬步,稳扎稳打型
  ◎ Richard Chilton /Chilton投资公司
  规模:43亿美元
  类型:拣股者
  地址:Stamford,康涅狄格州
  使康涅狄格州格林威治成为世界对冲基金圣地的先驱者之一。大都会艺术博物馆董事会成员。美式家具的爱好者,共和党的拥护者。老手评价“:在建立一个伟大组织同时也能创立一个伟大基金的典型范例。此外,还有一群很棒的孩子。”
  ◎ Larry Robbins /Glenview资本管理公司
  规模:61亿美元
  类型:拣股者
  地址:曼哈顿
  过去曾为Leon Cooperman的欧米加顾问公司(Omega Advisor)工作。一度赌马。
  老手评价:“去年境况不太好,但是他就像收购业务的传奇英雄LeonCooperman一样,完全为自己的事业疯狂了。”
  对冲基金投资人:“大事制造者。”
  新手:“利用各种策略的大人物。”
  ◎ Richard Perry /Perry资本
  规模:123.4亿美元
  类型:交易员
  地址:曼哈顿
  太太在为民主党筹款方面十分活跃,过去3届大选中为民主党捐赠超过100万美元。和许多顶级对冲基金经理人一样出身高盛,是EddieLampert的哥们儿。由于在King制药公司的交易中有可疑的举动被SEC调查。一度拥有鲜花和礼品速递公司FTD集团。
  ◎ Lief Rosenblatt /卫星资产管理公司(Satellite Asset Management)
  规模:54亿美元
  类型:交易员
  地址:曼哈顿
  曾经是索罗斯的下属。罗兹奖学金获得者(Rhodes scholar)。生活低调。
  老手评价:“伟大的套利者,索罗斯的门徒。似乎对快速成长不感兴趣,而更关注于优雅的生活。”
  新手:“岂弟君子,急公好义。”
犯难涉险,一击必杀型
  ◎ T. Boone Pickens /BP资本管理
  规模:25亿美元
  类型:交易员
  地址:达拉斯
  义无反顾地做多石油成就了他的第一桶金。大慈善家,2005年捐赠额超过了2亿美元。估计拥有净资产25亿美元。
  老手评价:“发家于能源业,过去从能源公司赚钱,现在转行做对冲基金。”
  新手评价:“赌得很大,有好几次差一点就倾家荡产。”
  ◎ Timothy Barakett /Atticus资本
  规模:140亿美元
  类型:拣股者
  地址:曼哈顿
  曾经回绝去新泽西魔鬼队(NewJerseyDevils)打职业冰球的机会。长期关注全球股票交易,包括纽约证交所、泛欧交易所(Euronext)和德国证交所(Deutsche Boers)。
  老手评价:“毫无疑问,一位伟大的全球拣股者。”
  新手评价:“此公家族的基因里有某种神秘的东西,他的兄弟Brett也在经营一家对冲基金,叫Tremblant资本。”
  ◎ Stephen Mandel /孤松资本(Lone Pine Capital)
  规模:79.4亿美元
  类型:拣股者
  地址:康涅狄格州格林威治
  Julian Robertson老虎基金培养出的“小老虎”之一。最近一次成功是选中了Google。和许多成功的对冲基金经理人一样出身高盛。
  老手评价:“真正的劲敌。一个安静、私密的家伙。他的公司可能是这一行里组织得最好的。如果这一行里有哪一家公司在创始人退下来后还能存在并继续发展繁荣,孤松是最好例子。”
  新手:“年收入2.5亿美元。”
  ◎ James Chanos /Kynikos Associates
  规模:30亿美元
  类型:拣股者
  地址:曼哈顿
  少有的几个靠卖空从1990年代的大牛市中全身而退的人之一。很早发现安然(Enron)的问题,并透露给《财富》杂志记者Bethany Mclean,让后者一举成名。当然,在这个过程中自己也发了财。
  老手评价:“卖空交易高手,深思熟虑,但不是一个交易者。”
  新手:“过去10年中最棒的、纯粹的短线投资者,看在上帝的份上,他竟料到安然会出事!”
芝兰玉树,后生可畏型
  ◎ Chase Coleman /老虎全球管理(Tiger Global Management)
  规模:30亿美元
  类型:拣股者
  地址:曼哈顿
  老虎基金培养出来的“小老虎”。荷兰驻新阿姆斯特丹殖民地(今纽约)总督Peter Stuyvesant的后裔,正是此公的这位先人建起了让华尔街因之得名的那道墙。钟情于小公司股票。
  老手评价:“一位优秀的全球投资者,从容且有章法地建立起自己的事业。”
  对冲基金投资人评价:“现在不仅关注技术股,还做点风险投资。”
  ◎ Peter Thiel /Clarium资本管理公司
  规模:19亿美元公司
  类型:交易员
  公司地址:旧金山
  不收固定管理费,只拿25%提成,很少有对冲基金这么做。PayPal共同创始人。信奉自由意志,美国保守派学生报纸《斯坦福评论》创始人。副业包括风险投资,投资过Friendster、Facebook 和 li<x>nkedln等公司。电影《感谢你抽烟》的执行制片人。
  ◎ William von Mueffering /Cantillon资本管理
  规模:81亿美元
  类型:拣股者
  地址:曼哈顿
  曾供职于国际投资银行Lazard,其间,靠投资于科技类和通信类公司一举成名,该银行能够在对冲基金业务中占有一席之地也应归功于此公。2003年从Lazard辞职。喜欢收集黑白照片,国际摄影中心(International Center for Photography)董事会成员。
  对冲基金投资人评价:“离开Lazard时孤立无援。他们真应该花点努力留住他。”
  新手评价:“迅速升起的明星。”
  ◎ Eric Mindich /Eton Park
  规模:62亿美元
  类型:交易员
  地址:曼哈顿
  高盛历史上最年轻的合伙人。在高盛风险套利部门赢得声誉。
  老手评价:“评价他还太早,他出手很大,但最近的交易可不怎么样。人人都想知道究竟出什么事了。”
  新手评价:“史上在首发时募集资金数额最大的对冲基金。”
  ◎ David Ganek /Level全球投资
  规模:N/A
  类型:拣股者
  地址:康涅狄格州格林威治
  SAC的第一位雇员,之后自己创业。在艺术收藏界的名声与其在投资领域不相上下。崇拜后现代艺术大师杰夫·孔斯(Jeff Koons)。在寸土寸金的纽约公园大道740 号拥有住所。老手评价:“出色的财富管理者,稳健、可靠。”
  新手评价:“与前老板Steve Cohen在艺术收藏上志趣相投。”
  ◎ John Arnold /Centaurus能源公司
  规模:30亿美元
  类型:交易员
  地址:休斯敦
  前安然交易员。美国参议员DianneFeinstein指责他的公司操纵美国能源市场。雇用了很多安然事件的“倒霉鬼”。天然气期货交易专家。据说是Amaranth崩盘的受益者。
  对冲基金投资人:“这小子刚刚在RichardBranson(英国大富豪,维珍集团老板)的私人小岛上结婚。还是个可怕的能源交易员。”
《外交政策》杂志日前对全球规模最大5只对冲基金进行盘点,分析了其投资策略。
  1.摩根大通资产管理公司
  总资产:330亿美元
  所在地:纽约
  投资方向:各种领域均有投资,包括一系列静态套利产品。该基金在中国、印度等国家投资房地产业。近一段时间以来,该基金开始涉足基础设施领域,例如投资德克萨斯州的高速公路。此外,该基金正在逐渐拓展亚洲市场,并刚刚获得在韩国运营的牌照。
  投资策略:多样化。摩根大通资产管理公司雇佣了多名投资经理,各自采用不同的投资策略。该基金宣称追求金融工具数量与质量的平衡,并据此来评估风险和回报。不过,该基金目前主要致力于“完全回报投资”,即不考虑市场整体走势,仅以实现投资目标为最终目的。
  2.高盛资产管理公司
  总资产:325亿美元
  所在地:纽约
  投资方向:该基金的投资方向一直保密。不过,全球市场的股票是该基金的一个重点投资对象,尤其是一些估值较低的股票。该基金的其他投资方向包括货币市场、固定收入资产、私募基金、风投基金以及基础设施等领域。
  投资策略:该基金倾向于投资一些未得到充分研究的市场,并追求一些套利机会。该基金大量使用依赖于市场模型计算的数量化投资策略。由于次级债风波,该基金旗下的两只基金今年以来损失了30%的市值。
  3.Bridgewater Associates
  总资产:302亿美元
  所在地:康涅狄格州Westport
  投资方向:货币市场,全球固定收入资产,债券,新兴市场,货物。最近开始投资股票市场。
  投资策略:大量采用数量化投资策略。该基金目前追求向客户提供高alpha,即通过投资独立于市场整体走势的股票来获取收益。该基金的客户多为机构性投资者,例如外国政府、中央银行、大学基金、养老金基金以及慈善基金等。
  4.D.E.Shaw集团
  总资产:273亿美元
  所在地:纽约
  投资方向:收购现有公司,尤其是濒临破产的公司。向新兴公司注资。其他投资包括风投基金、债券、能源业等。该基金近年来开始涉及私募基金并尝试直接借贷。
  投资策略:选择最好的投资经理。据透露,该基金的每一位投资经理均是从500名应聘者中挑选出来的。D.E.Shaw是数量化投资策略的先行者,通过数学方法和计算技术得出最佳的投资方式。采用高新技术是该公司的一大特色,该公司自称为“全球投资与技术发展公司”。
  5.Farallon资本管理公司
  总资产:262亿美元
  所在地:旧金山
  投资方向:债券与股票市场,公司的并购与重组,风投基金,房地产以及新兴市场。
  投资策略:大量的套利,例如在风险投资及公司并购等领域。该基金的客户包括大学基金和全球超级富翁,业绩在很大程度上受市场事件驱动。该基金对上市公司的动向密切关注,寻求增值机会。例如,该基金在近日的次级债危机之后以较低的价格投资了房地产市场。

Source: 海归论坛 :: 阅读主题 – [分享]对冲基金精英榜(Elite of the Hedge Fund)

October 11, 2007

Writing and Compiling A Simple Program For OpenWrt

Filed under: Uncategorized — manoftoday @ 5:03 am

 

Writing and Compiling A Simple Program For OpenWrt

Written by Eric Bishop <ericpaulbishop-at-gmail.com>

Part I added 8/23/2007
Part II added 10/10/2007

Introduction

I’m writing this document because I found the documentation available on the OpenWrt wiki (http://wiki.openwrt.org) difficult to follow. I found myself in the position of wanting to compile a very simple program that I could run on my OpenWrt router. I ended up spending hours wading through the frustratingly incomplete documentation on the wiki, going through dozens of forum posts, and conducting extensive trial-and-error before my code would compile. I especially appreciated the examples on the wiki that contain the warning: “Note this Makefile is provided as an example only; it will not compile.” If something doesn’t work, it isn’t a very good example, is it? Here, then, is a (hopefully) more straightforward guide to building a program for OpenWrt. I found that existing documentation focuses more on porting existing, complicated programs to OpenWrt. My intention is to focus on getting a small, very simple, home-grown application running on OpenWrt. My goal is to explain this in as simple and complete a manner as possible, explaining each and every step necessary to write and compile a program that will run on OpenWrt. The process is actually very simple and straightforward — provided you know what you’re doing. For the purposes of this tutorial I’m going to assume you have a development box running linux and a router running OpenWrt. I will also assume you are at least somewhat familiar with C/C++ and standard Unix Makefiles.

The code for the examples in this tutorial can be downloaded from here. The example from the first part of the tutorial is in the openwrt-programming-examples/c directory and the example from the second part is in the openwrt-programming-examples/c++ directory.

Part I: A Simple Program in C

First, we’re going to need to write the code for the program itself and get it compiling on our local linux machine. Let’s write a simple “hello world” program that we want to run on the router:

~/helloworld/src/helloworld.c:

/****************
* Helloworld.c
* The most simplistic C program ever written.
* An epileptic monkey on crack could write this code.
*****************/
#include <stdio.h>

int main(void)
{
	printf("Hell! O' world, why won't my code compile?\n\n");
	return 0;
}
	

Alright, we have our code. Note the location of this file. Make a helloworld directory and then a src subdirectory. Place the code in the src subdirectory. Now, let’s write a standard Unix Makefile to compile this code for us:

~/helloworld/src/Makefile:

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
	$(CC) $(CFLAGS) -c helloworld.c

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

Notice that instead of hard-coding “gcc” in the makefile to compile the program, we use a variable that holds the C compiler, $(CC). If you’re compiling a c++ program you would use $(CXX) instead of $(CC) and $(CXXFLAGS) instead of $(CFLAGS). The use of the compiler variable is not necessary to compile the code locally, but in order to compile the code for OpenWRT it is critical because we won’t be using the standard gcc compiler. Place the makefile in the same src directory our code is in. We can now go to the src directory, type “make” and the program should compile. You can run it by typing “./helloworld”

mockingbird@linuxbox:~/helloworld/src$ make
cc -c helloworld.c
cc helloworld.o -o helloworld
mockingbird@linuxbox:~/helloworld/src$ ./helloworld
Hell! O' world, why won't my code compile?

mockingbird@linuxbox:~/helloworld/src$ make clean
rm *.o helloworld
mockingbird@linuxbox:~/helloworld/src$ 
	

So far this should be a review on how to write simple C programs and how to use Makefiles. Now comes the tricky part, compiling the code so that it will run on our router. The router uses a distinctly different architecture than our linux development box. Because there isn’t enough memory/disk space on the router to install a compiler and compile the code natively, we need to “cross-compile” the code on our development box for use on the router. To do this we need a special compiler and development environment called the OpenWRT SDK. You can download the SDK from http://downloads.openwrt.org The SDK varies depending on the architecture of your development box, the architecture of your router and the version/release of OpenWrt your router is running. I currently have whiterussian v0.9 installed on my Linksys WRT54G router, and my development box is an i686, so the SDK I use is this one. Extract the SDK files from the downloaded archive, and enter the SDK directory, which should have the same name as the tar.bz2 file (in my case OpenWrt-SDK-Linux-i686-1).

mockingbird@linuxbox:~$ tar xfj OpenWrt-SDK-Linux-i686-1.tar.bz2
mockingbird@linuxbox:~$ cd OpenWrt-SDK-Linux-i686-1
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ ls
dl  docs  examples  include  Makefile  package  README.SDK  rules.mk  scripts  staging_dir_mipsel
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ 
	

Our goal is to build a package for OpenWrt using the source we already have. When you execute the “make” command in the SDK directory, the SDK will compile all properly configured packages in the package subdirectory under the SDK directory. The next step (and the trickiest) is to properly configure our code so that the SDK will build it. First, copy the helloworld directory we made earlier into the package subdirectory of the SDK:

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ cp -r ~/helloworld package
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ 
	

In order to tell the OpenWrt SDK how to build our program we need to create a special Makefile in the helloworld directory, above the src directory which contains our conventional makefile. Writing this file is 90% of the work involved in compiling our program for OpenWrt. Below is an OpenWrt makefile for building the helloworld program. Each section is heavily commented so that it should be fairly clear what is going on:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/Makefile:

##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to 
# specify a basic description of the package, 
# where to build our program, where to find 
# the source files, and where to install the 
# compiled program on the router. 
# 
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and 
# there should be no trailing whitespace in
# lines that are not commented.
# 
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# This specifies the directory where we're going to build the program.  
# The root build directory, $(BUILD_DIR), is by default the build_mipsel 
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk



# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/helloworld
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Helloworld -- prints a snarky message
	DESCRIPTION:=\
	If you can't figure out what this program does, \\\
	you're probably brain-dead and need immediate \\\
	medical attention.
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef


# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one


# Specify where and how to install the program. Since we only have one file, 
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running 
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install 
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the 
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
	

As indicated, most OpenWrt make files specify how to download the source of an application from a URL, and most documentation assumes that you want to do this. However, if you’re building your own application from scratch it doesn’t make sense to download from a URL. It’s much simpler to have the source locally and use the Build/Prepare section to copy the source to the build directory, as shown above. Also, be very careful of spacing in the Makefile. The indentation under the define sections should be tabs, not spaces and there should be no whitespace at the end of lines that are not comments. The trailing whitespace can be a problem when variables are being defined, as the compiler may think there is a space at the end of a directory name. If we’re copying something to dir_with_trailing_space/subdir the copy command may be executed as “cp my.file dir_with_trailing_space /subdir”. Not only don’t you want anything in /subdir, you probably dont have permission to create it and write to it.

Now we’re all set to compile the helloworld package. Go to the root SDK directory (if you’re not already there) and type “make V=99” The “V=99” option is optional, but it is useful for debugging as it instructs the compiler to be “verbose” and output all the details of what it is doing.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make V=99
make package/compile
make[1]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
Collecting package info...
make -C package compile SDK=1
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make -j1 compile-targets
make[3]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make -C helloworld compile
make[4]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package/helloworld'
CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " LDFLAGS="-L/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib " make -C /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " ARCH="mipsel" ;
make[5]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
make[5]: `helloworld' is up to date.
make[5]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
touch /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/.built
install -d -m0755 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin
install -m0755 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/helloworld /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/
mkdir -p /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name CVS | xargs rm -rf
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name .svn | xargs rm -rf
find /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name '.#*' | xargs rm -f
STRIP="/home/mockingbird/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/sstrip" STRIP_KMOD="mipsel-linux-uclibc-strip --strip-unneeded --remove-section=.comment" /home/mockingbird/OpenWrt-SDK-Linux-i686-1/scripts/rstrip.sh /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld
rstrip.sh: /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/helloworld:executable
ipkg-build -c -o 0 -g 0 /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages
Packaged contents of /home/mockingbird/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld into /home/mockingbird/OpenWrt-SDK-Linux-i686-1/bin/packages/helloworld_1_mipsel.ipk
make[4]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package/helloworld'
make[3]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[1]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
( \
        cd package; \
        find . -maxdepth 2 -name Config.in | \
                sed -e 's,/Config.in,,g' | \
                xargs -r -n1 make compile -C; \
)
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$
	

It compiled! The new package, helloworld_1_mipsel.ipk, is now located in the bin/packages subdirectory of the root SDK directory.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ cd bin/packages
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ ls
helloworld_1_mipsel.ipk
mockingbird@linuxbox:~OpenWrt-SDK-Linux-i686-1/bin/packages$
	

This file is a ipk file which is used by the ipkg (itsy package management) system. Ipkg is a package management system for embedded devices, where space is an issue. Let’s copy this package onto the router, which is located at 192.168.1.1 on my network.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ scp helloworld_1_mipsel.ipk root@192.168.1.1:
root@192.168.1.1's password: 
helloworld_1_mipsel.ipk                                                            100% 1875     1.8KB/s   00:00    
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ 
	

Now, ssh into the router. We just copied the package to root’s home directory so we are finally ready to install our program. In root’s home directory, (where we end up immediately after connecting to the router via ssh) type “ipkg install helloworld_1_mipsel.ipk” and the ipkg system will do the rest.

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1/bin/packages$ ssh root@192.168.1.1
root@192.168.1.1's password: 


BusyBox v1.00 (2007.01.30-11:42+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 WHITE RUSSIAN (0.9) -------------------------------
  * 2 oz Vodka   Mix the Vodka and Kahlua together
  * 1 oz Kahlua  over ice, then float the cream or
  * 1/2oz cream  milk on the top.
 ---------------------------------------------------
root@OpenWrt:~# ls
TZ                       ip-up                    resolv.conf              spool
dhcp.leases              log                      resolv.conf.auto         usr
helloworld_1_mipsel.ipk  net                      run
root@OpenWrt:~# ipkg install helloworld_1_mipsel.ipk
Installing helloworld (1) to root...
Configuring helloworld
Successfully terminated.
root@OpenWrt:~# 
	

The executable has now been installed into the /bin directory on the router, per our instructions in the OpenWrt Makefile listed above. So, all we have to do to run the program is type “helloworld” at the prompt. Note that because the executable has been installed to the /bin directory you should be able to execute the program no matter what directory you are in on the router.

root@OpenWrt:~# helloworld
Hell! O' world, why won't my code compile?

root@OpenWrt:~# 
	

It works! Great success!

 

Now that you have a simple program compiling, you can start expanding on it to do whatever you want. If you run into problems I suggest you browse existing package Makefiles to see if someone else has done something similar to what you are trying to do. You can browse the files for these packages here. If you still have problems, browse the posts on the developer forum to see if anyone else has had a similar problem. If not, post your problem to the forum with a detailed explanation of what you’re trying to do, your OpenWrt Makefile and the errors you’re getting. Hopefully, some experienced developer will be kind enough to help out. Please do not email me personally if you have a problem with your code. If, however, you believe there is an error or serious omission in this tutorial, please let me know. I am relatively new to working with OpenWrt and it is certainly possible that I’ve made a mistake somewhere in this document. I have, however, personally tested all code included here on my own setup, and made every effort to be as accurate as possible.

Good luck with your programming!

Part II: C++ and the Standard Template Library (STL)

If you only want to compile C programs, the first part of my tutorial should be enough to get you started. However, if you want to use C++ there is another issue you’re likely to run into. Let’s say we want to compile the following C++ program for OpenWrt:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/helloworld.cpp:

/****************
* Helloworld.cpp
*****************/
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s = "Hell! O' world, why won't my c++ code run?\n\n";
	cout << s;
	return 0;
}
	

So, let’s do exactly as we did before and see what happens. We just have to update the compiler flags in the Makefile to indicate that we’re using a C++ compiler instead of a C compiler, right?

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/Makefile:
NOTE: This code will compile but not run, further modifications are needed which are described below

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CXX) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.cpp
	$(CXX) $(CXXFLAGS) -c helloworld.cpp

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

If you use the exact same OpenWrt Makefile as before, this program will compile just fine. It will even install properly when you copy the helloworld_1_mipsel.ipk file to the router and type “ipkg install helloworld_1_mipsel.ipk” However, watch what happens if you try to run the program:

root@OpenWrt:~# helloworld
helloworld: can't load library 'libstdc++.so.6'
root@OpenWrt:~#
	

So, what went wrong? The problem is that this program uses strings and iostreams which are a feature of the C++ standard template library (STL). However, because memory is so critical in an embedded application like OpenWrt, the standard template library is not available. Instead, we need to link to a special implementation of the standard library for embedded devices called uClibc++. This library implements the same functions and data structures as the standard library but takes up less memory.

Before we adjust our Makefiles to use to this alternate library, let’s first make sure that it’s installed on the router so that it is available to link to. Log into your router. Then, make sure your list of packages is up to date by using the “ipkg update” command:

root@OpenWrt:~# ipkg update
Downloading http://downloads.openwrt.org/backports/0.9/Packages
Updated list of available packages in /usr/lib/ipkg/lists/0.9-backports
Downloading http://download2.berlios.de/pub/xwrt/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/X-Wrt
Downloading http://downloads.openwrt.org/whiterussian/packages/Packages
Updated list of available packages in /usr/lib/ipkg/lists/whiterussian
Downloading http://downloads.openwrt.org/whiterussian/packages/non-free/Packages
Updated list of available packages in /usr/lib/ipkg/lists/non-free
Successfully terminated.
root@OpenWrt:~# 
	

Once you have updated your package list, install uclibc++ by typing “ipkg install uclibc++” If you do not have uclibc++ installed this should install it:

root@OpenWrt:~# ipkg install uclibc++
Installing uclibc++ (0.1.11-2) to root...
Downloading http://downloads.openwrt.org/whiterussian/packages/uclibc++_0.1.11-2_mipsel.ipk
Configuring uclibc++
Successfully terminated.
root@OpenWrt:~# 
	

Otherwise, if the library is already installed, you’ll see this confirmation:

root@OpenWrt:~# ipkg install uclibc++
Package uclibc++ (0.1.11-2) installed in root is up to date.
Nothing to be done
Successfully terminated.
root@OpenWrt:~# 
	

Now it’s time to modify the Makefiles. First, the one in the src directory. Only a small change is necessary here, to the line where we link the objects together. We need to be able to tell the linker to link to another library, and the way we do that is by defining a variable called $(LIBS). The variable will be defined in the special OpenWrt Makefile, but will be used here, so we need to add it to the end of the line which specifies how to do the linking:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/src/Makefile:

# build helloworld executable when user executes "make"
helloworld: helloworld.o
	$(CXX) $(LDFLAGS) helloworld.o -o helloworld $(LIBS)
helloworld.o: helloworld.cpp
	$(CXX) $(CXXFLAGS) -c helloworld.cpp

# remove object files and executable when user executes "make clean"
clean:
	rm *.o helloworld
	

The OpenWrt Makefile needs a slightly more complex modification. Recall the comment I placed in the OpenWrt Makefile we used before, “We do not need to define Build/Configure or Build/Compile directives. The defaults are appropriate for compiling a simple program such as this one.” Well, guess what? In order to link to uclibc++ we need to customize how we’re going to compile the program, and we’re going to do this in the Build/Compile directive. Before we re-define this directive to suit our purposes, let’s see what the default looks like:

TAKEN FROM: ~/OpenWrt-SDK-Linux-i686-1/include/package.mk:

define Build/Compile/Default
	CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
	LDFLAGS="$(EXTRA_LDFLAGS) " \
	$(MAKE) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		CROSS="$(TARGET_CROSS)" \
		CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) " \
		ARCH="$(ARCH)" \
		$(1);
endef
	

This code specifies the make command (the third line) and a bunch of flags and parameters for compilation. In order to link to uClibc++ we add the definition of the $(LIBS) variable as “-nodefaultlibs -lgcc -lc -luClibc++” Also, we need to specify “-nostdinc++” in the compiler flags to tell the compiler that c++ standard template library functions and data structures will be linked to in specified external libraries and not the standard libraries:

~/OpenWrt-SDK-Linux-i686-1/package/helloworld/Makefile:

##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to 
# specify a basic description of the package, 
# where to build our program, where to find 
# the source files, and where to install the 
# compiled program on the router. 
# 
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and 
# there should be no trailing whitespace in
# lines that are not commented.
# 
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# This specifies the directory where we're going to build the program.  
# The root build directory, $(BUILD_DIR), is by default the build_mipsel 
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk



# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/helloworld
	SECTION:=utils
	CATEGORY:=Utilities
	TITLE:=Helloworld -- prints a snarky message
	DESCRIPTION:=\
	If you can't figure out what this program does, \\\
	you're probably brain-dead and need immediate \\\
	medical attention.
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef



#########################################################################################
# The Build/Compile directive needs to be specified in order to customize compilation
# and linking of our program.  We need to link to uClibc++ and to specify that we 
# do NOT want to link to the standard template library.
#
# To do this we define the LIBS variable.  To prevent linking to the standard libraries we 
# add "-nodefaultlibs" to the $(LIBS) variable and then specify "-lgcc -lc" to ensure that 
# there are no unresolved references to internal GCC library subroutines. Finally 
# "-luClibc++" to link to the  uClibc++ library.  Also, we need to specify "-nostdinc++" 
# in the compiler flags to tell the compiler that c++ standard template library functions
# and data structures will be linked to in specified external libraries and not the 
# standard libraries.
#########################################################################################
define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		LIBS="-nodefaultlibs -lgcc -lc -luClibc++" \
		LDFLAGS="$(EXTRA_LDFLAGS)" \
		CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) -nostdinc++" \
		$(TARGET_CONFIGURE_OPTS) \
		CROSS="$(TARGET_CROSS)" \
		ARCH="$(ARCH)" \
		$(1);
endef


# Specify where and how to install the program. Since we only have one file, 
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running 
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install 
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the 
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
	$(INSTALL_DIR) $(1)/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
	

That’s it! That modification should be sufficient to enable linking to uClibc++. Compile it as before, copy the .ipk file to the router, install it with ipkg and run it:

mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make clean
rm -rf build_* bin
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ make
make package/compile
make[1]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
Collecting package info...
make -C package compile SDK=1
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Entering directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[4] -C package compile-targets
make[5] -C package/helloworld compile
make[2]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1/package'
make[1]: Leaving directory `/home/mockingbird/OpenWrt-SDK-Linux-i686-1'
( \
        cd package; \
        find . -maxdepth 2 -name Config.in | \
                sed -e 's,/Config.in,,g' | \
                xargs -r -n1 make compile -C; \
)
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ scp bin/packages/helloworld_1_mipsel.ipk root@192.168.1.1:
root@192.168.1.1's password: 
helloworld_1_mipsel.ipk                                                100% 2570     2.5KB/s   00:00    
mockingbird@linuxbox:~/OpenWrt-SDK-Linux-i686-1$ ssh root@192.168.1.1
root@192.168.1.1's password: 


BusyBox v1.00 (2007.01.30-11:42+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 WHITE RUSSIAN (0.9) -------------------------------
  * 2 oz Vodka   Mix the Vodka and Kahlua together
  * 1 oz Kahlua  over ice, then float the cream or
  * 1/2oz cream  milk on the top.
 ---------------------------------------------------
root@OpenWrt:~# ipkg install helloworld_1_mipsel.ipk
Installing helloworld (1) to root...
Configuring helloworld
Successfully terminated.
root@OpenWrt:~# helloworld
Hell!  Why won't my c++ code run?
root@OpenWrt:~# 
	

It works! Our Jedi programming skills have prevailed!

Once again, please do not contact me about any issues you might have with your own programs. If, however, you think there is an error in one of my examples or that I have omitted a critical detail, please contact me and I will try to resolve the issue as soon as possible.

This tutorial is provided under the Creative Commons License, version 3.0.

Source: Writing and Compiling A Simple Program For OpenWrt

Error 1068 When Starting WZC – Tech Support Forum

Filed under: Uncategorized — manoftoday @ 3:41 am

 

Today I became aware that my computer also had this problem (HP dv100 with Intel (R) Pro/Wireless Adapter), so I did an extensive search on the internet to get it to work (including this post).
As you mention it, if you try to start the WZCSVC service in the MMC, an error code appears referring to its parent services appears (1068, this parent services are Remote Procedure Call and something called NDIS Protocol [I have no idea what this is… ¬¬]). So, if you check the RPC service, it must be enabled (system essential), but you cannot find the other “service”.
I have also seen answers referring to disabling any 3rd Party Wireless Management Software (but I don’t have one, so it cannot be that).
However, I did find such Protocol Service in the regedit, and I found out it was disabled (it was set to 4). So, in sum, I recommend you to go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Ndisuio
and check that the “Start” Value is set to 1, 2 or 3 (I set it to 1).
And this solved my problem, after a System Restart the Wireless Zero Config Service can be readily started.
Note: today I found a couple of Win32 Trojan and Worms and a fake service called DirectX.exe, located on the System Directory and considered as a Blaxe and LogPole Virus o_O (I already got rid of it). Maybe they had something to do with this problem.
I hope this works for you, and if it does, there are many posts on other forums related to this, maybe you can spread the info.

Source: Error 1068 When Starting WZC – Tech Support Forum

October 10, 2007

Tunneling trafiic over SSH with OpenWRT, DynDNS and Putty

Filed under: Uncategorized — manoftoday @ 12:57 am

 

1)  Tunneling HTTP over SSH

To connect to the SSH server and tunnel HTTP you will need the Putty SSH client.

To connect to your router enter the hostname or IP address of your router on the Session tab:



Next, to setup the tunnel.  click on Tunnels, enter 3000 (or whatever local port you’d like to use) for the source port, click Dynamic and click Add. This will create a SOCKS proxy on your local machine on port 3000 (or whatever port your chose) that you can use with your web browser.

Now you can click Open to log into your router. The tunnel isn’t created until you log in. Remember that your username is root and your password is your router password (you changed it right?).

Now you’re ready to connect your web browser. Using Firefox, you will have to configure a proxy server. Click Tools->Options->advanced. Then under Network tab, click on Settings… button . On the popup window screen, you can configure the SOCKS proxy that you’ve set up using Putty. Select Manual proxy configuration, enter localhost for the SOCKS host and 3000 for the port (or whatever you used). Click OK. You should now be tunneling through your home router over ssh.  after the setting, you have to close ALL OPENED firefox windows and restart Firefox to make it effect.

 

You can verify that the connections are being forwarded by looking at the Putty Event Log. You should see something similar to the following after loading www.google.com in your web browser.

or verify by closing the putty session, then you won’t be able to view any webpage.

 

Source: Random Bits: HOWTO: Tunneling HTTP over SSH with DD-WRT, DynDNS and Putty

2)  Tunneling VNC over SSH

       https://manoftoday.wordpress.com/2006/10/07/putty/

 

3)  Tunneling RemoteDesktop over SSH

Configure PuTTY for auto-login (if you choose to use PuTTY):

suppose sshd is on port 22 in your wireless router which has OpenWrt.

open putty

- type in your dyndns ip address of your router
- choose port 22
- connection -> SSH -> Tunnels
- source Port: 127.0.0.2:3390  <--- NOTE here, mstsc can't connect to 127.0.0.1, so we have to use 127.0.0.2
- Destination -> ip_address_of_your_home_PC_Server_behind_OpenWrt:3389   (if remote desktop is used)
- press add
- open the connection to your router
- if you don't have free internet access, you can use also a proxy server to connect.
- if proxy is needed: connection -> proxy
- proxy type: http
then run windows terminal service client: mstsc , and connect to 127.0.0.2:3390

in the following example, home windows server is running at 192.168.1.8 with both windows terminal service running at port 3389(default) and VNC services at 5900(default)

 
 

4)  Configure PuTTY for auto-login

Configure PuTTY for auto-login (if you choose to use PuTTY):

  1. Make a shortcut to putty.exe on your Desktop
  2. Right click the shortcut, Properties > Shortcut tab > Target field
  3. Add the following to the end of the string in the field: -load “[your profile name]” -l [login name] -pw [password]
  4. Example: -load “home” -l Mark -pw mypassword

October 6, 2007

DD-WRT Solution for Random Resetting to Default – complete guide

Filed under: Uncategorized — manoftoday @ 6:31 am

 

This is a complete guide on how to recompile the DD-WRT source code to modify default factory settings for your own use. The need for this came up because the dd-wrt router on my client site keeps resetting back to default and the forum provided no clear fix for it. The procedures described here were proven to work on my machine. This guide is exactly the same as the one in wiki Ddwrtmodificationhowto in our company webpage so if you are from my work then you can print it from there.
tools needed for doing this:
.fedora core 6 with all development tools such as gcc 4.1.1 installed (in my case it runs on virtual pc)
.latest source code as of now (1210-2006-svn5216.snapshot.tar.bz2 from downloads/sourcecode section)
.toolchains (toolchains.x86.debian.sp1.tar.bz2) from the bottom of the downloads/source section, for compiling
steps:
1.unpack the source code with: tar xvf 1210-2006-svn5216.snapshot.tar.bz2
2.move the unpacked directory DD-WRT to /
3.unpack toolchains into /opt
4.create links to the directories for compile scripts:
cd /
ln -s /DD-WRT/image GruppenLW
cd /opt
ln -s 3.4.6-uclibc-0.9.28 3.4.6
ln -s 3.4.6-uclibc-0.9.28 3.3.4
ln -s 3.4.6-uclibc-0.9.28 3.3.6
ln -s 4.1.0-uclibc-0.9.28 4.1.0
5.add toolchain to your path: export PATH=$PATH:/opt/4.1.0/bin/
6.change permission for certain files:
chmod +x /DD-WRT/src/router/iptables/extensions/.dccp-test
chmod +x /DD-WRT/src/router/iptables/extensions/.layer7-test
7.compile some stuff first:
cd /DD-WRT/src/linux/brcm/linux.v23
cp .config_std .config
make oldconfig
make dep
8.save the following script(thanx to tornado) as /DD-WRT/script1.sh:
#!/bin/bash
export MYPATH=$PATH
export PATH=/opt/4.1.0/bin:$MYPATH
cd /DD-WRT/src/router/busybox/scripts
rm -f bb_mkdep *.o
gcc bb_mkdep.c -o bb_mkdep
cd /DD-WRT/src/squashfs-tools
rm -f *.o mksquashfs-lzma
make
cp mksquashfs-lzma /DD-WRT/src/linux/brcm/linux.v23/scripts/squashfs
cp mksquashfs-lzma /DD-WRT/src/linux/brcm/linux.v24/scripts/squashfs
cd /DD-WRT/tools
rm strip
rm write3
rm write4
make strip
make write3
make write4
gcc -o webcomp -DUEMF -DWEBS -DLINUX webcomp.c
cd ../src/router/tools
rm jsformat
make jsformat
9.save the following script(thanx to tornado) as /DD-WRT/script2.sh:
#!/bin/sh
echo “#define BUILD_DATE \”$(date +%D)\”” > build.h
export PATH=/opt/4.1.0/bin:$PATH
cd ../src/linux/brcm/linux.v23
#cd ../src/linux/brcm/linux.v24
cp .config_std .config
make clean
make oldconfig
cd ../../../router
rm -dfr mipsel-uclibc/install
make clean
cd ../../opt
10.give permission to those scripts:
chmod ugo+rwx /DD-WRT/script1.sh
chmod ugo+rwx /DD-WRT/script2.sh
11.now the last step before compiling is edit the default factory settings. The file to modify is /DD-WRT/src/router/services/defaults.c. To know the right variable to modify simple ssh into your dd-wrt router and do: nvram show >list.txt
from the list.txt you will get an idea which variable is which. Then simply search string for the variable name in defaults.c and modify the middle argument. Two things that will not be affected by the modification of defaults.c is lan_ipaddr and wep keys. These will need to be changed in rc_startup variable. Add a startup script to rc_startup to change them: {“rc_startup”, “nvram set lan_ipaddr=192.168.11.1\nnvram set rc_startup=\nnvram commit\nreboot”, 0}, note the \n is escape sequence for c++ string.
12.now compile the damn thing with:
cd /DD-WRT
./script1.sh
./script2.sh
cd /DD-WRT/opt
./install_normal.sh
13.the binary files created will be in /GruppenLW/
You need to follow this instruction exactly for it to work. And I have not tested it against anything other than fedora core 6 combined with sp3 source code so any other combo may or may not work!

Source: DD-WRT Forum :: View topic – Solution for Random Resetting to Default – complete guide

October 2, 2007

Shopping: Ten Great Wines for $10 or Less – Lifehacker

Filed under: Uncategorized — manoftoday @ 12:13 am

 

Casa Cadaval Portugal Ribatejano , $8.99, ***
Domaine de l’Ameillaud France , $9, ** ½
Viña Gormaz Spain Ribera del Duero , $9, **
Georges Duboeuf France , $9, **
Altas Cumbres Argentina Mendoza , $9, **
Wyatt California Cabernet Sauvignon 2005 , $10, **
J. Vidal-Fleury France , $10, **
Domaine Monte de Luz , $7, **
Ravenswood California Vintner’s Blend , $10, **
Paringa , $9, * ½

Source: Shopping: Ten Great Wines for $10 or Less – Lifehacker

Blog at WordPress.com.